Have you tried a different status code to see if that works? 409 is a really specific code that the resource is busy and is not used often.
Feb 21, 2020
3
Level 1
Response with status code is failing.
I'm using:
- Lumen 6x
- Laradock (lastest)
I am returning a simple array, but it does not work as expected. Example:
return response()
->json(
['foo' => 'bar']
, 409
);
// returns {"data":[],"message":{},"status":409,"success":false}
But if I comment the status code, it works well:
return response()
->json(
['foo' => 'bar']
// , 409
);
// returns {"foo":"bar"}
At first I thought it was a JSON issue, but the normal response behaves the same.
return response(['foo' => 'bar'], 409);
// returns {"data":[],"message":{},"status":409,"success":false}
return response(['foo' => 'bar']);
// returns {"foo":"bar"}
In other projects I have used a template for response and it has always worked for me. Now, with this problem I stopped using it and the problem persists. I already cleaned cache and it still doesn't work. The template is like this:
[
'data' => $data,
'message' => $message,
'status' => $code,
'success' => false,
]
At the moment I can live without the status code, because I am in local development. But as soon as the API arrives with the people of the APP, they will surely require it.
Please or to participate in this conversation.