Is there a way to NOT show an HTML error from an API?

The recommended way of handling errors in Nitro/API-land is to use createError. When hit directly, these show a full html error page, or if hit with accept: application/json, show a json payload with stack info.

I'd like to return a simple message on-error vs all that. It would seem the only option I have is to use setResponseStatus and return whatever directly from the api vs passing something to createError.

IMHO, no matter what, an api shouldn't be returning full page html errors.
Was this page helpful?