there is post request with api:
axios.post(‘https://api.myapp.com:8000', formData).then(function (response) {
}).catch(function (error) {
console.log(error)
})
I get here response with “xhr” type. In console I see only:
Error: Request failed with status code 422
at createError (createError.js?2d83:16)
at settle (settle.js?467f:18)
at XMLHttpRequest.handleLoad (xhr.js?b50d:77)
to do something like error.data the push content into my alert bar.
What I tried is:
error.responseType, error.response, error.responseBody, error.status, for every of this calls I get simple undefined. Under network in console I see the content like needed.
How can I get content from such response?
Solution :
Change you catch statement like the following. I hope it will work.
.catch (error) {
console.log(error);
}
Solution 2:
I found this solution and it works for me:
axios.post(‘https://api.myapp.com:8000', formData).then(response => {
console.log(response)
}).catch(error => {
console.log(error.response)
})