Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

297
Views
¿Cómo obtener el iniciador de solicitud con titiritero?

Estoy tratando de registrar todas las solicitudes de red en una página. Mi objetivo es filtrar más tarde solicitudes particulares y verificar su iniciador. El siguiente código funciona bien si comento la línea 12 const request_initiator = interceptedRequest.initiator(); . Pero el iniciador es algo realmente necesario. De acuerdo con los documentos del titiritero, lo estoy llamando correctamente.

Aquí está mi código:

 const puppeteer = require('puppeteer'); (async() => { const results = []; const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.setRequestInterception(true); page.on('request', interceptedRequest => { const request_url = interceptedRequest.url(); const request_method = interceptedRequest.method(); const request_payload = interceptedRequest.postData(); const request_initiator = interceptedRequest.initiator(); results.push({ request_url, request_method, request_payload, request_initiator }) interceptedRequest.continue(); }); await page.goto('https://testurl.com'); await browser.close(); return results })().then(function(result) { console.log(result) });

Aquí está el error que estoy recibiendo:

 UnhandledPromiseRejectionWarning: TypeError: interceptedRequest.initiator is not a function at /Users/test/Desktop/code/tagv2/tcv2/index.js:12:54 at /Users/test/Desktop/code/tagv2/tcv2/node_modules/peteer/lib/cjs/vendor/mitt/src/index.js:51:62 at Array.map (<anonymous>) at Object.emit (/Users/test/Desktop/code/tagv2/tcv2/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43) at Page.emit (/Users/test/Desktop/code/tagv2/tcv2/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22) at /Users/test/Desktop/code/tagv2/tcv2/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:143:100 at /Users/test/Desktop/code/tagv2/tcv2/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62 at Array.map (<anonymous>) at Object.emit (/Users/test/Desktop/code/tagv2/tcv2/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43) at NetworkManager.emit (/Users/test/Desktop/code/tagv2/tcv2/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22) (node:22974) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:22974) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
about 4 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 Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!