Nuxt.js 3 State is Prefix with 's'

50 views Asked by At

I'm new to Nuxt.js 3 and I couldn't find the reason why it is being prefix with 's'. Here is my code.

    import { ISession } from "~/types/ISessions";

export async function registerWithEmail(
    username: string,
    name: string,
    email: string,
    password: string
) {

    try {
        const res = await $fetch<ISession>('/api/auth/register', {
            method: 'POST',
            body: { data: { username, name, email, password } }
        })

        if (res) {
            useState('user').value = res
            useState('userr').value = res
            useState('xxx').value = res
            await useRouter().push('/dashboard')
          }
    }
    catch (e) {
        // console.log('error' + e.toString())
    }


}

In the console log when I check the state. It looks like this. enter image description here

0

There are 0 answers