0

I'm coding a test website with NodeJS .

I use Vue and Nuxt for the client-side.

I use the auth library of Nuxt JS for user signup.

The problem is that in Vuex no logged in user is displayed and no user is logged in.

My signup code is :

            let data = {
                name : this.name ,
                email  : this.email,
                password : this.password
            }
            let response = await this.$axios.$post(`/api/auth/signup` , data);
            console.log(response)

                await this.$auth.loginWith('local' , {
                    data : {
                        email : this.email ,
                        password : this.password
                    }
                });
                await this.$router.push('/')

and my auth options of nuxt.config.js is :

auth: {
localStorage : true , 
strategies: {
  local: {
    endpoints: {
      login: { url: '/api/auth/login', method: 'post', propertyName: 'token' },
      user: { url: '/api/auth/user', method: 'get', propertyName: 'user' }
    }
  }
}

}

this is my state of vuex user is showing : enter image description here

what is exactly my problem??

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
farid
  • 1
  • Can you provide a sample of the server response for the login and user endpoints? Is nuxt saving the token correctly in the client side? (you can check that inspecting the cookies or local storage). Have you checked that your user endpoint actually returns an object named 'user'? – Guillermo Bruchmann Dec 27 '20 at 18:56
  • What do you get when you do `console.log(response)`? and can you share code of your vuex mutation? where are you adding the response to the `user` object? – painotpi May 17 '21 at 15:38

0 Answers0