Helpers
All helper functions are available within event but can also be top-level imported from @xinkjs/xink.
redirect
Section titled “redirect”Returns a redirect response.
export const 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.
export const 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.
export const 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.
export const GET = (event) => { return event.json({ hello: 'world' })}