[Vuejs]-How to retrieve token property in Nuxt Auth

0👍

I think an alternate way would be to set local.token.required:false , and then set the user token after your login attempt was successful. Something like this:

nuxt.config.js

auth: {
    strategies: {
      local: {
        token: {
          required: false
        },
        user: {
          property: 'data',
          autoFetch: true
        },
        endpoints: {
          login: { url: '/en/signin', method: 'post' },
          logout: { url: '/user/logout', method: 'get' },
          user: { url: '/en/user/profile', method: 'get' },
        }
      }
    }
  },

Login.vue

     methods: {
              async userLogin() {
                try {
                  let response = await this.$auth.loginWith('local', { data: this.login })
                  .then((response)=>{
  this.$auth.setUserToken(response.data[0].access_token,'refreshToken');
                  });
                  console.log(response);
                } catch (err) {
                  console.log(err)
                }
              }
            }

Leave a comment