Answer the question
In order to leave comments, you need to log in
Axios does not return an object if the response from the server is not 200 - what should I do?
I'm writing server requests using axios (inside VueJS) and I've run into a problem that if the response status is not 200 (422 for example), then I can't access the object returned by the server (in catch()
).
I tweaked ajax - everything is fine, an object with an error is returned and I can read it.
In axios, the following answer is returned, which I output to the console: Error: Request failed with status code 422
- just a string.
Is it possible somehow to get this error?
Answer the question
In order to leave comments, you need to log in
try {
axios.get(/* ... */)
} catch(error) {
console.log(error.response)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question