[Vuejs]-Unable to access returned error response in Axios from Laravel Lumen API

4👍

try this err.response catch error data is inside response

this.$axios.post(`${process.env.API_URL}/api/domains/add`, this.domainCreation).then(res => {
    console.log(res)
  }).catch(err => {
    console.log(err.response);
  })

ref link https://github.com/axios/axios#handling-errors

0👍

In addition to the above answer, you should consider returning the correct response codes.

5xx error codes are for Internal Server Errors. You are probably looking to return a 422 unprocessable entity error.

More info about 500 status code: https://httpstatuses.com/500

More info about 422 status code: https://httpstatuses.com/422

Leave a comment