I'm trying to get the specific token value from this response in the outside of the loop so then i can show this token value in the HTML page.
import puppeteer from 'puppeteer-extra'
var http = import('http');
puppeteer.launch({ headless: true }).then(async (browser) => {
const page = await browser.newPage();
const token=[];
await page.goto('https://orbitxch.com/customer/inplay/highlights/1');
page.on('request', req => {
const tok = req.headers()
console.log(tok)
});
});
Response:
'x-csrf-token': 'c7474114cc5e6b5e5deda9f46a9978dd69',
'sec-ch-ua-mobile': '?0',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/100.0.4889.0 Safari/537.36
Wants to get the x-csrf-token value in a variable. right this command returns the entire website HTTP header so there are lots of x-csrf-token but all are the same I just want one token in token varaible. any nodejs expert?
i tried this:
const token=[];
await page.goto('https://orbitxch.com/customer/inplay/highlights/1');
page.on('request', req => {
const tok = req.headers()
token.push(tok) // but this not working it return []
console.log(tok)
});