Reputation: 316
I have custom error messages returning from the server and i get it in the xhr.responseText.
{"timestamp":1544419441358,"status":900,"error":"Http Status 900","message":"Origin already exists","path":"/origin/add/"}
I need to get the status code from the above return response. I have tried following way
But i cannot get that error 900. What i am getting is undefined.
So how to get the status code from the response text.
Upvotes: 2
Views: 4650
Reputation: 68933
I believe responseText is string, you have to parse the response first:
var responseText = JSON.parse(xhr.responseText);
var status = responseText.status;
Upvotes: 4