damien-hl/nuxt3-auth-example

Error: useBody is not defined

DougHayward opened this issue · 1 comments

Whilst trying to run this repo I'm hitting the following error when trying to login.

useBody is not defined

As defined here:

const body = await useBody<{ email: string; password: string; rememberMe: boolean }>(event)

In order to get the repo to run at all I had to change:

const cookie = useCookie(event)[config.cookieName]

To:

const cookie = getCookie(event, config.cookieName) || 0

Without this change I get the error:

useCookie is not defined

Any pointers would be greatly appreciated. I'm attempting to move from Nuxt 2 to Nuxt 3 and using this repo to replace Nuxt-Auth.

Hello Doug,

In a recent update, useBody had been renamed to readBody.

// Old
const body = await useBody<{ email: string; password: string; rememberMe: boolean }>(event)

// New
const body = await readBody<{ email: string; password: string; rememberMe: boolean }>(event)

Same applies to useCookie, which has been renamed to getCookie.

Nuxt3 uses some h3 composables for server routes, you can find them here.

Thank you for pointing this out! I will update the repo soon.