0

After login, page should redirect on dashboard component and it does but then again redirect on laravel app url

enter image description here

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'});
                }
            })
        }
    }

1
  • 1
    I think you need to add Event as a parameter and preventDefault before the axios method. Commented Apr 29, 2022 at 9:02

1 Answer 1

0

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'});
                }
            })
        }
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.