[Vuejs]-Error: in Vue consuming Rails Api, data received but Vue can't read

0👍

You would call this.loggedUser if it was in data. But you have set it as constant.

async signin () {
  try {
    console.log('base rute is: ', process.env.VUE_APP_ROOT_API)
    const response = await Api.post('users/login', {
      user: {
        email: this.email_input,
        password: this.password
      }
    })
    const loggedUser = response.data
    console.log('this is login response data: ', loggedUser)
    this.$store.commit('set_token', loggedUser.auth_token) 
    this.$store.commit('set_user', loggedUser.user)
    localStorage.setItem('token', loggedUser.auth_token)
    localStorage.setItem('user', JSON.stringify(loggedUser.user))
    this.$emit('authenticated', true)
  } catch (err) {
    console.log('login error: ', err)
  }
  }

Leave a comment