Skip to content
Advertisement

Laravel validation always returns 200 OK from API

I want to separate my validator with my controller, but API always responds with a 200 OK in Postman.

Request validation:

JavaScript

SenderController:

JavaScript

When I’m sending a request without name, it will return a response with a status of 200. I want to display $validator->errors() in my response when I forget to input name. How can I do that?

Postman

Route and call:

JavaScript

Advertisement

Answer

I solved the problem with adding more code in my PostRequest.php

JavaScript

and I show the error message by using controller

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement