puppeteer/new-docs/puppeteer.httprequest.redirectchain.md
Jack Franklin f7857d27c4
chore(docs): document HTTPRequest with TSDoc (#6146)
* chore(docs): document HTTPRequest with TSDoc

* doclint

* example
2020-07-03 14:28:45 +01:00

1.2 KiB

Home > puppeteer > HTTPRequest > redirectChain

HTTPRequest.redirectChain() method

Signature:

redirectChain(): HTTPRequest[];

Returns:

HTTPRequest[]

the chain of requests - if a server responds with at least a single redirect, this chain will contain all requests that were redirected.

Remarks

redirectChain is shared between all the requests of the same chain.

For example, if the website http://example.com has a single redirect to https://example.com, then the chain will contain one request:

const response = await page.goto('http://example.com');
const chain = response.request().redirectChain();
console.log(chain.length); // 1
console.log(chain[0].url()); // 'http://example.com'

If the website https://google.com has no redirects, then the chain will be empty:

const response = await page.goto('https://google.com');
const chain = response.request().redirectChain();
console.log(chain.length); // 0