Skip to content

get final url #4571

Locked Answered by carlos-dubon
jimmywarting asked this question in Q&A
Discussion options

You must be logged in to vote

You can access it by accessing response.config.url or response.request.responseURL, though if you only want the URI you would need to use regex or you could use JS by utilizing a array or string method.

Example:

const axios require('axios');
const url = require('url');

axios(req)
  .then(response => {
    const parsedURL = url.parse(response.config.url);
    console.log(parsedURL.host);
  })
  .catch(err => console.error(err));

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jasonsaayman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants