eons
eons

Reputation: 456

how do i redirect from vue-component to a laravel route without using vue-router

I am trying to redirect from a Vue-component to a Laravel route using window.location but a get a 404 error page.

This is the page that i am redirected to

http://127.0.0.1:8000/admin/stocks/[object%20Promise]

This is my code to redirect me to laravel route from vue-component

    async onSave() {
        this.errors = {};
        await Api().post('/stocks/store',this.form)
        .then((response)=>{
           window.location = Api().get('/stocks/'+response.data.id+'/show');
        })
        .catch((error) => {
              if(error.response.status === 422) {
                    this.errors = error.response.data.errors
              }
           })
  }

Upvotes: 0

Views: 132

Answers (1)

Mamtora Mohit
Mamtora Mohit

Reputation: 34

Use <A> tag to redirect page

let link = document.createElement('a')
link.href = "Your XYZ Link"
link.click()

Upvotes: -1

Related Questions