I cannot get the response text in the 500 error
with axios.
in Network tab in dev tools i can find the error message like this
{"Message":"500 error message 0","Code":0,"Type":"error"}
and I use
axios()
.then(function(done) {
//fine and can get done.data
})
.catch(function(error) {
console.log(error.message);
});
but I can only get
Request failed with status code 500
so how can I get the response text with axios
axios. get('/user/12345') . catch(function (error) { if (error.
Reload or Refresh the Webpage Most of the time, the issue is only temporarily and can be corrected by trying the page again. You can use the refresh/reload button, pressing F5 , or by trying the URL again from the address bar.
To solve 500 HTTP Internal Server Error, reload a web page. You can do that by clicking the refresh/reload button, pressing F5 or Ctrl + R, or trying the URL from the address bar again. The issue might be temporary even if the 500 Internal Server Error is the web server's problem.
By default, the axios HTTP library throws an error anytime the destination server responds with a 4XX / 5XX error (for example, a 400 Bad Request ). Since axios raises an error, your workflow will stop at this step.
according to axios readme:
axios.get('/user/12345')
.catch(function (error) {
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
}
console.log(error.config);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With