0👍
You need to return a JSON error handle if you are using an API call.
The Laravel default error handling for validation is to throw Exception thru the blade that you can access as $errors
If you want to make your own validation use the validator
facade.
use Illuminate\Support\Facades\Validator;
use Illuminate\Http\Request;
public function store(Request $request) {
$validation = Validator::make($request->all(), [
'name' => 'required',
'email' => 'required',
'password' => 'required',
]);
if($validation->fails()) {
return response()->json([
'status' => 'failed',
'message' => $validation->errors(),
], 400);
}
}
0👍
Thank you to those who commented or answered. I did actually figure it out. I added a couple of functions into my Exceptions/Handler.php file. I built this SPA based off of a Free Youtube Course and I grabbed the code that I placed in the Handler.php file after following a different paid course on Udemy. I didn’t think these functions would cause any harm but they did. After removing them, everything is working great and back to normal. Thank you.
- [Vuejs]-Creating a custom tab navigation component
- [Vuejs]-Vue – Detect if element been added to v-for object
Source:stackexchange.com