I'm working with Laravel 5.6 as my backend for a personal project and i've been doing something that seems (to me) as a bad practice, either way, I would like to know if it is actually that bad.
First of all, i'm using a Vue.js (CLI 3) project as a client and i'm making requests to my Laravel backend. Now, to deal with the notifications/toasts, i'm using the next format:
return response()->json([
'alert' => [
'title' => 'Server error.',
'text' => 'Error explanation text.',
'type' => 'error'
]
], 200);
It doesn't matter if I everything went right or wrong, i am always responding with this same format and an 200 status
. Is it wrong? Should I use other statuses on my responses?
I am doing this because i can't get (i don't know how) the custom 'alert' array on my client side while using a 404
status (for example) and the only way I could find to deal with it was using this 200
status every single time.