Folky.H Folky.H - 2 months ago 9x
JSON Question

How can I access to this value of this key in this JSON?

I would like to read the error message inside _body.

Currently, what I do is:


However, I am getting undefined.

When I do console.log(message._body);

I get "{"code":141,"error":"This phone number exists already!"}"

var message = {
"_body":"{"code":141,"error":"This phone number exists already!"}",
"statusText":"Bad Request",

By the way the following comes form the backend like this and I can't change its format neither remove the double quotes

"_body":"{"code":141,"error":"This phone number exists already!"}"

How can I read the error message?


In your case you need to convert it to json using the json() method after getting the error from your backend.

The following one should work fine with you: