Working with Vue.js and Laravel stack
I’m still learning web development and I’m stuck on something. After a user successfully logs into my Laravel backend API, I want to automatically redirect them to a different page on my Vue frontend. Right now, my login works fine, but the user stays on the same login page even after authentication succeeds.
Here’s my current login method:
async handleUserLogin() {
try {
const loginResponse = await axios.post("api/user/authenticate", {
username: this.userEmail,
userPassword: this.userPass,
});
// Store the auth token
localStorage.setItem("authToken", loginResponse.data.access_token);
// Need to redirect to dashboard here somehow
} catch (err) {
this.showLoginError = true;
setTimeout(() => {
this.hideError();
}, 3000);
}
}
What’s the best way to navigate to another route after the login is successful? Should I use Vue Router for this?