How can I access context's req in Nuxt3?

105 Views Asked by At

How can I access context's req in Nuxt3?

nuxt2

asyncData({req}) {
const body = req.body;
}

I used useRequestEvent().req.body and useNuxtApp().event.req.body. but both is undefined.

nuxt3

const event = useRequestEvent()
const body = event.req.body;

const nuxtApp = useNuxtApp()
const { ssrContext } = nuxtApp;
const body = ssrContext.event.req.body

Is there another way to access request body?

0

There are 0 best solutions below