Skip to content

Instantly share code, notes, and snippets.

@ajmcagadas
Created October 30, 2017 23:32
Show Gist options
  • Select an option

  • Save ajmcagadas/ca69f9e64f257f88a2983fb55f14025d to your computer and use it in GitHub Desktop.

Select an option

Save ajmcagadas/ca69f9e64f257f88a2983fb55f14025d to your computer and use it in GitHub Desktop.
Capture laravel error on axios promise
let key = Object.keys(error.response.data)[0];
if(error.response.status === 422) {
swal('Oh snap!', error.response.data[key][0], "error");
} else {
swal('Error!', error.message, "error");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment