Laravel – Vuejs – Axios – Capturing Validation error

A quick snippet on how to capture Laravel's 422 error on the front-end. https://gist.github.com/allaniftrue/67d78a0c18ab7610e69687f06d998903

Advertisements

Capturing Laravel’s Error On Axios

Axios is a promised based http client.  Capturing laravel's 422 status error is a bit tricky because the returned data is a dynamic json key.  Here is a simple approach on how we can capture the error status code and throw an error using sweet alert 2. https://gist.github.com/allaniftrue/ca69f9e64f257f88a2983fb55f14025d