I want to return the response of axios but always the response that returned is undefined:
wallet.registerUser=function(data){
axios.post('http://localhost:8080/register',{
phone:data.phone,
password:data.password,
email:data.email
}).then(response =>{
return response.data.message;
console.log(response.data.message);
}).catch(err =>{
console.log(err);
})
}
console.log(wallet.registerUser(data));
The console always logs as undefined. Is their any way returning this response.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…