Im trying to catch validation errors from the server.
Code:
axios.post('',Data)
.then(res=>{
console.log(res)
}).catch(error=>{
console.log(error)
})
Console log output
Error: Network Error
at createError (createError.js:16)
at handleError (xhr.js:87)
Network tab output
{"error":{"message":"Check your date field","status_code":500}}
Is there a way to change that or I'm doing something wrong?
Thanks!
Im trying to catch validation errors from the server.
Code:
axios.post('https://myBackendIp./api/teacher/time/create',Data)
.then(res=>{
console.log(res)
}).catch(error=>{
console.log(error)
})
Console log output
Error: Network Error
at createError (createError.js:16)
at handleError (xhr.js:87)
Network tab output
{"error":{"message":"Check your date field","status_code":500}}
Is there a way to change that or I'm doing something wrong?
Thanks!
Share Improve this question asked May 21, 2019 at 10:41 Sanjeevan RajakulasingamSanjeevan Rajakulasingam 511 silver badge8 bronze badges 1- i can't understand your question..? you are always handling async call exception right – Hamit YILDIRIM Commented May 21, 2019 at 10:43
1 Answer
Reset to default 5After Googling a little, I found this ticket:
https://github./axios/axios/issues/960
It remends using:
console.log(error.response)
instead of
console.log(error)
Edit 1:
Did some further reading, apparently this could be a symptom of a CORS issue, see this and this.
The request on the network tab might seem like it's succeeding, however, when it's processed by Axios, a Network Error
is returned.