Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel validation return status 302

Tags:

laravel

I have a form and I can send data through and get data in controller and see it but when use validation as below:

$validation= $request->validate([
  'title' => 'required|unique:posts|max:255',
   'body' => 'required',
   'message' => 'required'
  ]);

I have status 302 I don't know what to do

like image 280
negar Avatar asked Nov 28 '22 13:11

negar


1 Answers

Http Status Code 302 means that the API (server) requests a redirect. That is the expected behavior of Laravel validation if the validation do not pass. If you want Laravel to return json instead, add the following key value pair to your request headers.

accept: application/json
like image 86
Hilmi Erdem KEREN Avatar answered Jan 23 '23 13:01

Hilmi Erdem KEREN