'Phalcon: setStatusCode returns empty response
I'm trying to write error handling for one of the endpoints in phalcon.
If I set status code to client/server error code(4xx/5xx), then the response returned is empty. How can I fix that?
Example:
$test = [
"test message"
];
$response->setHeader('Content-Type', 'application/json')
->setStatusCode(200)
->setJsonContent($test)
->send();
In browser network tab, I get this as response (which is completely fine)
["test message"]
but if I just change the statusCode to say, 500
->setStatusCode(500)
I get empty response
Solution 1:[1]
Remove the following line,
setHeader('Content-Type', 'application/json')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Codemaker |