Categories
JavaScript Answers

How to get the redirected URL from the Node request module?

Spread the love

To get the redirected URL from the Node request module, we use the request property.

For instance, we write

const request = require("request");
const r = request.get("http://example.com", (err, res, body) => {
  console.log(res.request.uri.href);
});

to make a get request with request.get.

We get the redirect URL from the res.request.url.href property.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *