0
votes

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
              }
           })
  }
1
why u dont use this.$router.push(``)latenight
@CamB$oKiDz cannot use $router.push is i am not building a single page applicationeons

1 Answers

-1
votes

Use <A> tag to redirect page

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