• Jobs
  • About Us
  • Jobs
    • Home
    • Jobs
    • Courses and challenges
  • Businesses
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

375
Views
Trying to get the specific token value in variable, Puppeteer NODEJS

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)
 });
over 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.

Andres GPT

Show me some job opportunities
There's an error!