NinetyHH
NinetyHH

Reputation: 1464

Lumen does send 204 response

I have created the following function into the main Controller.

public function noContent() : JsonResponse
{
    return response()->json([], Response:HTTP_NO_CONTENT);
}

When deleting some data, I am returning the above function but I get a message that "Could not get any response".

I also have tried to pass a message (even if this is not recommended for a 204) in the array but still, I receive the same error. I am using the same function to return 200 or 404 messages and there worked as expected.

Is there another solution to make this work?

Upvotes: 2

Views: 2168

Answers (1)

Masi
Masi

Reputation: 41

You should do:

return response('', 204);

Upvotes: 4

Related Questions