Only JSON outputs


I am building an API with Slim framework and I would be interested in only having JSON outputs, not only for routes but for every error or message that the framework would throw. Is this possible?

Thank you.

This happens by default if the client sets their Accept header to application/json.

Otherwise, you can override the error handling to do force it yourself.

1 Like

That’s great.


What if I wish to force JSON output ?

I think I found the solution by using withJson() !