how to redirect to another component in vue 3 using AXIOS after getting API response inside ( then block )

624 Views Asked by At

I am trying to implement some code based on HTTP status code in success response using AXIOS call , How can i access the status code of HTTP response header , and redirect to anoenter image description herether component in vu3

2

There are 2 best solutions below

0
On

Assuming your code is something like. const response = await axios.post("<url>"); You can check with if (response.status === 200). Read the full response schema here.

1
On

you can use response.status to tap into the status code

response.status


    app.get("/",(req,res)=> {
        //your code
        console.log(response.status);//this will console the status of the request
    });