Response Helpers
Horn includes a small set of response helpers for loaders, actions, and server routes.
json(data, init?)
Returns a JSON Response and sets content-type to application/json; charset=utf-8 if not already present.
redirect(url, status?)
Returns a redirect Response. The default status is 302.
badRequest(data, init?)
Returns a JSON Response with status 400 by default.
isResponse(value)
Type guard for checking whether a value is a Response.
readResponseData(response)
Reads a response body based on its content type:
- JSON for
application/json - text for
text/* nullfor204and205ArrayBufferotherwise