When I call Lumen, it's always return the header with the response no matter the method. Why?
Here is the router :
$router->group(['prefix' => 'test'], function() use ($router) {
$router->post('an', 'MyController@anAction');
});
This is an action from my controller
public function anAction(Request $request): string {
$return['result'] = true;
return response()->json($return);
}
And this is the response :
HTTP/1.0 200 OK Cache-Control: no-cache, private Content-Type: application/json Date: Thu, 02 May 2019 14:54:35 GMT {"result":true}
How can I just have this?
{"result":true}
I just ran into this issue, was caused by the typehint return on the function:
public function anAction(Request $request): string {
That was converting the response to a string rather than the Illuminate\Http\JsonResponse it actually is. Changing it to this solved my issue.
public function anAction(Request $request): \Illuminate\Http\JsonResponse {