Yes I had that problem too
.catch(error => {
this.onFail(error.response.data);
reject(error.response.data);
});
And besides you don't need to put the whole axios call in a promise... it's a promise already.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I followed Jeffery's Vue2.0 series. For whatever reasons I am not able to post the question on that video. Let me try it here.
I am using axios to make the HTTP request to post the data. It's working perfectly finem but when when I try to submit the empty body (which I shouldn't) I don't see the error message in the span block down there. I get something like this in the console.
POST http://..../statuses 422 (Unprocessable Entity) /#/:1 Uncaught (in promise) Object {ob: Observer}
Network preview shows:
{body: ["The body field is required."]} body: ["The body field is required."]
Here's the code that makes use of Axios.
eturn new Promise((resolve, reject) => {
axios[requestType.toLowerCase()](url, this.getData())
.then(response => {
this.onSuccess(response);
resolve(response);
})
.catch(error => {
this.onFail(error);
reject(error);
});
});
What if you pass the error handler into the then method?
...
.then(
(response) => { handleResponse(response); },
(error) => { handleError(error); }
)
...
Please or to participate in this conversation.