D
D
danilr2019-03-21 19:23:21
Vue.js
danilr, 2019-03-21 19:23:21

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)
          })
      })
    }

here I call action from the component
saveAction() {
      this.$store
        .dispatch("administration/saveAction", this.formAction)
        .then(response => {
          this.$toast.success("Action успешно создан");
        })
        .catch(error => {
          this.$toast.error("Ошибка получения данных, попробуйте снова");
          console.log(error);
        });
    }

like this in the console it shows the error
5c93ba16906de329074352.png
as seen in the network, the object is still there
5c93ba62744e5554758238.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
monochromer, 2019-03-21
@danilr

Axios Handling Errors
https://github.com/axios/axios#handling-errors

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question