この関数を使用して値を返すことはできません。外部変数をAxios外に設定する方法
getNameById (id) {
var name = ''
axios.get('/names/?ids=' + id)
.then(response => {
this.response = response.data
name = this.response[0].name
})
.catch(e => {
this.errors.push(e)
})
// Is empty
console.log('Name ' + name)
return name
}
"then"内のname変数にアクセスして返しますか?
をはい、それは私から – John