• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Pruebas Online
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

298
Vistas
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)
 });
almost 3 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda