Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

435
Visualizações
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)
 });
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda