Exception format it's pretty nice while where creating a fullstack app, the problem is when whe use Adonis for API development, the error it's kinda unreadable while using tools like Postman. It would be so much readable use the Acept header and return a format dynamic response.
Actually, make a simple handler with adonis make:ehandler with
async handle(error, {response}) {
response.status(error.status).json({
message: error.message,
error: error.name
})
}
works pretty fine. But I think it would be a better developement experiencie just done this by default.
Let me hear in what I can help.
Hey @MarcoMacedoP! 馃憢
Adonis is Content Negotiation to generate the response for this kind of thing.
If you are receiving HTML while sending a request using a tool like Postman it's because you send a bad request. Ensure to have the Accept header with application/json when you send your request.
If you are 100% sure to only have JSON output, you can create a middleware that force this header for any request.
Closing since no response from the issue reporter and not actionable as well
Most helpful comment
Hey @MarcoMacedoP! 馃憢
Adonis is Content Negotiation to generate the response for this kind of thing.
If you are receiving HTML while sending a request using a tool like Postman it's because you send a bad request. Ensure to have the
Acceptheader withapplication/jsonwhen you send your request.If you are 100% sure to only have JSON output, you can create a middleware that force this header for any request.