I can't get variable "account" in this Vue.js source in a part.
export default {
data() {
return {
visible: true,
account: '',
password: '',
sso: '',
}
},
methods: {
submit() {
if (this.account == '') {
return alert('Please enter your ID.')
} else if (this.sso==0 && this.password == '') {
return alert('Please enter your Password.')
}
let data = {
account: this.account,
sso: this.sso,
}
if(this.sso == 0 ){
data['password'] = sha256(this.password)
}else{
data['password'] = sha256('Demeter_'+this.account)
}
createLogin(data).then((res) => {
console.log('createLogin :: res', res)
if (res.status === 200) {
if (res.data.status == 409) {
return alert(res.data.message)
}
if(this.sso == 1){
Kakao.Auth.login({
success: function (response) {
console.log("Kakao.Auth.login - success response ->", response);
Kakao.API.request({
url: '/v2/user/me',
// property_keys: [
// 'properties.nickname'
// ],
success: function (response) { //'success function'
console.log("/v2/user/me - response.id ->"+ response.id)
console.log("data ->", data)
let data = {
accesstoken: res.data,
account: this.account, // account : undefined
}
console.log("/v2/user/me - data ->", data )
this.$store.dispatch('store/login', data)
},
fail: function (error) {
console.log(error)
return alert('Login failed')
},
})
},
fail: function (error) {
console.log(error)
},
})
}else{
let data = {
accesstoken: res.data,
account: this.account, // account : admin
}
console.log("else - data ->", data )
//this.$store.dispatch('store/login', data)
}
} else {
let message = res.data.message
alert(message)
}
})
},
}
}
When I uncheck sso(sso = 0), then it shows this.account as which is written in the account input box.
But if I check sso(sso = 1), then it showed this.account as undefined. I don't know why this happens. Is the reason that function is nested so? Then how can I use that account value in that 'success function'?