Helpers
All helper functions are available within event but can also be top-level imported from @xinkjs/xin.
redirect
Section titled “redirect”Returns a redirect response.
api.get((event) => { return event.redirect(307, '/login')})Returns an html response. It sends a Content-Length header, and a Content-Type header of text/html.
api.get((event) => { return event.html(`<div>You chose ${event.params.fruit}</div>`)})Returns a text response. By default, it sends a Content-Length header, and a Content-Type header of text/plain.
api.get((event) => { return event.text(`Hello World!`)})Returns a json response. By default, it sends a Content-Length header, and a Content-Type header of application/json.
api.get((event) => { return event.json({ hello: 'world' })})