There are bunch of ways you receive Laravel errors in front-end and inside your ajax request, you need to parse and display the errors nicely. Inside blade, it’s pretty easy to handle and display errors but inside javascript? In my projects, I realised a pattern that I was repeating myself for handling an error message properly.
I’ll use Vue in this example but you should be good to use it with other frameworks or even with vanilla javascript.
However, I wanted to handle it as: First, I create a global mixin inside my Vue called error-handling.js and attach it to my Vue instance.