Reputation: 185540
I search doc and the web, but can't find how to get the HTTP code of a query.
Anyone knows ?
Example :
const puppeteer = require('puppeteer');
const fs = require('fs');
const debug = true;
var base_url = 'https://stackoverflow.com/';
(async () => {
const browser = await puppeteer.launch({
headless: true,
});
const page = await browser.newPage();
await page.goto('https://stackoverflow.com');
// how to get HTTP code of last call ?
await browser.close();
})();
There's response.status() but don't know how to just fetch last query and not all with
page.on('response', response => {
console.log("response code: ", response.status());
});
Upvotes: 1
Views: 39
Reputation: 185540
OK, get it, thanks @Take_Care:
const puppeteer = require('puppeteer');
const fs = require('fs');
const debug = true;
var base_url = 'https://stackoverflow.com/';
(async () => {
const browser = await puppeteer.launch({
headless: true,
});
const page = await browser.newPage();
cons ret = await page.goto('https://stackoverflow.com');
console.log(ret.status());
await browser.close();
})();
Upvotes: 1