axios – on POST errors JSON response from api server not being printed

Posted on

When you POST from curl, you are getting the JSON response from the server that you setup.

On your frontend when trying to print the error to the console it’s not coming up. Instead you get the following:

xhr.js:166 POST MYURLHERE 400 (Bad Request)

Even if you print the whole error or JSON stringify the error you aren’t seeing the response

ANSWER

make sure you are printing error.response.data 

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s