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

156
Views
función que devuelve [promesa de objeto]

Estoy tratando de devolver el valor de la primera función y usarlo como variable en la segunda función, pero muestra este [object Promise] .

 addEventListener("fetch", event => { event.respondWith(fetchAndStream(event.request)) }); async function handleRequest(request) { var uri = request.url.replace(/^https:\/\/.*?\//gi, "/"); return uri; } async function fetchAndStream() { uri = handleRequest(); console.log(uri); // Fetch from origin server. let response = await fetch('http://blablabla.com/' + uri); const responseInit = { headers: { 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename="file.m3u"', } }; // ... and deliver our Response while that's running. return new Response(response.body, responseInit) }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Está llamando a sus funciones incorrectamente sin argumentos. Su handleRequest toma una solicitud de argumento en su declaración de función

 async function handleRequest(request)

En su detector de eventos, está llamando a la devolución de llamada con un argumento

 fetchAndStream(event.request)

Pero aquí no aceptas ningún argumento.

 async function fetchAndStream() { uri = handleRequest(); console.log(uri);

Dado que ha utilizado su función handleRequest con async. Devuelve un contenedor de promesa que esperará la ejecución, que tengo dudas de que se complete a partir de ahí. El contenedor es como un marcador de posición que se completará una vez que se complete su promesa, pero dado que no está llamando a las funciones correctamente. Por lo tanto, está obteniendo la salida.

about 4 years ago · Juan Pablo Isaza Report
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!