Is there an easy way to get `event`?
I use drizzle and cloudflare so I have an util like this one:
My issue is that I need always event and it's annoying to pass it around betwen functions. I know there is
useEvent()
but it requires an experimental asyncContext
which is not available on cloudflare.
How is everyone solving this?5 Replies
I would create a module to expose event: https://nuxt.com/docs/guide/going-further/modules
Found it!
You said event but you meant environment variables.
Glad you found your solution tho. 🙂
you should use useRuntimeConfig
Well originally I used
event
as event.context.cloudflare.env.DB
but now I found an alternative without event (using environment variables
)
I don't think bindings would be available in useRuntimeConfig()
no? That's some cloudflare specific thing, not normal env variables (they come from pi0/nitro-cloudflare-dev
)