0

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
              }
           })
  }
2
  • why u dont use this.$router.push(``) Commented Mar 17, 2020 at 5:57
  • @CamB$oKiDz cannot use $router.push is i am not building a single page application Commented Mar 17, 2020 at 9:21

1 Answer 1

-1

Use <A> tag to redirect page

let link = document.createElement('a')
link.href = "Your XYZ Link"
link.click()
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.