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

226
Views
¿Cuándo se rechazará la promesa Response.text ()?

Veo que en MDN/Response/text docs muestra el ejemplo de usar .text() solo con then

 response.text().then(function (text) { // do something with the text response });

Devuelve una promesa que se resuelve con un String.

Debido a las reglas de pelusa, necesito poner

 // eslint-disable-next-line @typescript-eslint/no-floating-promises res.text().then(async (t) => {

¿Hay algún caso de uso cuando necesito captar una promesa rechazada de Response.text() ? ¿Quizás algunos ejemplos?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede fallar/rechazar si la respuesta ya se consumed /leyó, es decir, si algo ya llamó .text/.json, etc.

Mirando la implementación de polyfill ( https://github.com/github/fetch/blob/d1d09fb8039b4b8c7f2f5d6c844ea72d8a3cefe6/fetch.js#L301 ) Sin embargo, no veo otros casos probables.


Ejemplo:

 response.text() .then(t1 => { console.log({ t1 }); // after calling text() we can see the result here return response; // but we decided to return the response to the next handler }) .then(res =>res.text()) // here we try to read text() again .then(t2 => console.log({ t2 })) // and expecting text to be logged here .catch(er => console.log({ er })); // but the text() promise rejects with // TypeError: Failed to execute 'text' on 'Response': body stream already read
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!