Answer the question
In order to leave comments, you need to log in
How to get an object with errors from a request via Axios?
I want to get an object with errors from a request through Axios, but a text with an error code comes in, in Networke I see this object, but for some reason I don’t get it through promises. I make the request in an action in vuex.
Here is the action in vuex:
saveAction(context, formData) {
return new Promise((resolve, reject) => {
HTTP.post(Routes.saveAction, formData)
.then(({
data
}) => {
context.commit('addAction', data)
console.log('data from saveAction', data);
resolve()
})
.catch(error => {
console.log('тут пытаюсь просмотреть ошибку error: ', error);
console.error(error);
reject(error)
})
})
}
saveAction() {
this.$store
.dispatch("administration/saveAction", this.formAction)
.then(response => {
this.$toast.success("Action успешно создан");
})
.catch(error => {
this.$toast.error("Ошибка получения данных, попробуйте снова");
console.log(error);
});
}
Answer the question
In order to leave comments, you need to log in
Axios Handling Errors
https://github.com/axios/axios#handling-errors
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question