-
Are set/get methods equivalent of express I want to share something from a middleware to another middleware or |
Beta Was this translation helpful? Give feedback.
Answered by
yusukebe
Mar 26, 2023
Replies: 1 comment 2 replies
-
Hi @ahmafi The answer is probably yes. Try this: type Variables = {
message: string
}
const app = new Hono<{ Variables: Variables }>()
app.use('*', async (c, next) => {
c.set('message', 'This is a message')
await next()
})
app.get('/', (c) => {
const message = c.get('message')
return c.text(message) // Hello!
}) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
ahmafi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @ahmafi
The answer is probably yes. Try this: