Is there a way to achieve the same functionality without using the async function?
async EnvioLogin() {
const response = await axios.post("api/auth/login", {
email: this.email,
password: this.password,
});
localStorage.setItem("token", response.data.token);
},
I attempted:
EnvioLogin() {
const response = axios.post("api/auth/login", {
email: this.email,
password: this.password,
});
localStorage.setItem("token", response.data.token);
},
However, I encountered the following error:
[Vue warn]: Error in v-on handler: "TypeError: Cannot read property 'token' of undefined"