Created
October 30, 2017 23:32
-
-
Save allaniftrue/ca69f9e64f257f88a2983fb55f14025d to your computer and use it in GitHub Desktop.
Capture laravel error on axios promise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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