'Vuejs + Laravel router redirection issue
After login, page should redirect on dashboard component and it does but then again redirect on laravel app url
Route : I have used Vue Router
const routes = [{
path: '/dashboard',
name: 'uDashboard',
component: uDashboard
}];
On Form Submit
methods: {
submit: function() {
axios.post('api/login', this.form).then(response => {
if (response.status == 201) {
this.$router.push({name: 'uDashboard'});
}
})
}
}
Solution 1:[1]
Make your code prevent the default action on form submit like so:
methods: {
submit: function(e) {
e.preventDefault(); // <-- added this
axios.post('api/login', this.form).then(response => {
if (response.status == 201) {
this.$router.push({name: 'uDashboard'});
}
})
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | geertjanknapen |

