Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
RunKit + npm: hono
node v18.11.0
version:
master
endpoint
share
tweet
const { Hono } = require('hono@2.1.2'); const { logger } = require('hono@2.1.2/logger'); const { cors } = require('hono@2.1.2/cors'); const app = new Hono(); app.use('*', logger()); app.use('*', cors({ origin: '*' })); app.get('/error', () => { throw new Error('Test error'); }); app.onError((err, ctx) => { return ctx.json({ error: true, status: 500, message: err.message, }); }); const main = async () => { const res = await app.request('http://localhost/error'); console.log([ ...res.headers.entries() ]); }; main();
Created from: https://npm.runkit.com/hono
Loading…
no comments
sign in
to comment