vendredi 3 août 2018

laravel bad request status message in console

can someone help me how can I pass error code and message to be able to parse it in a console for example...

in my case - if I don't set any status code it will return status code 200(even tho I use rules for validation) and I can see my custom message in the console logs

but when I set 400 status code I get generic message

$validator = Validator::make($request->all(),
            ['team.name' => 'required|unique:teams,name',
                'team.level' => 'required',
                'teamMembers.*.firstName' => 'required',
                'teamMembers.*.lastName' => 'required',
                'teamMembers.*.email' => 'required|unique:team_members,email',
                ]);

        if ($validator->fails()){
            return response()->json(['message' => $validator->errors()->first()],Response::HTTP_BAD_REQUEST);
        }

but when I go to network tab I can see my custom message...

how can I get that message to console?

and additional question... if I work on API like that is it OK to stay that way since I can see my message in network tab - as well in postman?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire