Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'data' of undefined #80

Open
kashtech79 opened this issue Aug 10, 2020 · 0 comments
Open

TypeError: Cannot read property 'data' of undefined #80

kashtech79 opened this issue Aug 10, 2020 · 0 comments

Comments

@kashtech79
Copy link

I try to store my login token but following error prevent storing data & produce following error
TypeError: Cannot read property 'data' of undefined

my login.vue is

export default {
data(){
return {
form:{
email: null,
password: null
}
}
},
methods:{
login(){
axios.post('/api/login',this.form)
.then(res => User.responseAfterLogin(res))
.catch(error => console.log(error.response.data))

user.js

class User{

responseAfterLogin(res){
    const access_token = res.data.access_token
    const username = res.data.name
        if (Token.isValid(access_token)) {
        AppStorage.store(access_token,username)
    }

can anyone help me on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant