Hi everyone, I’m working on a custom app for freshsales suite. So I need to handle this error
{
"errors": {
"code": 400,
"message": [
"The cf_field already exists"
]
}
}
I need to identify when this error occurs, in order to do that, I tried to access the error object in many different ways, like so:
await $request.put(`https://domain.myfreshworks.com/crm/sales/api/sales_accounts/${id}`, header_put)
.then(
function (data) {
//success logic
},
function (error) {
//logic when an error occurs
//i tried to see the error object in different ways
console.log(error.response.errors);
console.log(error.response.errors.message);
console.log(error.response.errors.message[0]);
//also tried to access message using an foreach because this attribute is a array
let message;
error.response.errors.message.forEach(text => {
console.log(text);
message = error.response.errors.message[text];
});
});
None of those ways worked and I don’t know what to do now. How can I access this attribute correctly?
Thanks!