Closed lightmyfire17 closed 4 years ago
Try to write the catch block like this:
.catch(async err => { let error = await err.response.json(); console.log('error: ', error); })
Hi @dekadentno
This has been fixed in https://github.com/nuxt/http/pull/113 and available in https://github.com/nuxt/http/releases/tag/v0.5.4
Keep in mind that err.response
can be undefined
if the request cannot hit the server.
Great, thanks.
Version
v0.5.0
Reproduction link
https://jsfiddle.net/eobk1pam/1/
Steps to reproduce
Use any HTTP Methods via $http ($get, delete, $put, etc.), try to catch the error like:
this.$http .$get("http://nuxthttperrors.io/error") .then(resp => console.log(resp)) .catch(e => console.log(e.response.data));
What is expected ?
Expected to get the error response message, like in
network
tab in chrome.P.S. Working like a charm in axios.
What is actually happening?
The error response object is always empty:
{ name: "HTTPError", response: {} }