Skip to content

Instantly share code, notes, and snippets.

@allaniftrue
Created October 30, 2017 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allaniftrue/ca69f9e64f257f88a2983fb55f14025d to your computer and use it in GitHub Desktop.
Save allaniftrue/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