rapidjs / rapid.js

An ORM-like Interface and a Router For Your API Requests
https://rapidjs.drewjbartlett.com
711 stars 45 forks source link

response on catch? #54

Open fenixphp opened 6 years ago

fenixphp commented 6 years ago

How to get a response from the server in "catch"?

    model
    .withParams(credentials)
    .post()
    .then((success) => {
      /* Set data. */
     commit('setUser', success.data.data.user);
    })
    .catch((error) => {
      if (error.data.data.message) {
        commit('setErrors', [error.data.data.message]);
      }
    });

Instead, the error object:

Error: Request failed with status code 422
    at createError (D:\Projects\Desionlab\Alex south\fastPanel\terminal\Source\node_modules\axios\lib\core\createError.js:16)
    at settle (D:\Projects\Desionlab\Alex south\fastPanel\terminal\Source\node_modules\axios\lib\core\settle.js:18)
    at XMLHttpRequest.handleLoad (D:\Projects\Desionlab\Alex south\fastPanel\terminal\Source\node_modules\axios\lib\adapters\xhr.js:77)

Thanks in advance.