Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
Response text is always empty event when repose exist
  1. I am fetching the PDF via URL, and want to check does that URL will return the document successfully.

  2. Sending a request via fetch()

  3. Get a response.text()

  4. Want to check does text exist

  5. Text is always empty

Cannot figure out why?

response.text() always returns empty text, even when PDF document exist in response.


  const handleOpenPDF = (url: any) => {
    fetch(url, {
      method: 'GET',
      mode: 'no-cors',
    })
      .then(res => res.text())
      .then(text => {
    enter code here
        // TEXT is always empty event when response is good
        console.warn('text', text);

        window.open(url, '_blank');
      })
      .catch(err => {
        console.warn('Error', err);
      });
  };
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Note that res => res.text() means read the body as a string. So it is good idea to use response.json() before you access to response. something like this:

const handleOpenPDF = (url: any) => {
    fetch(url, {
      method: 'GET',
      mode: 'no-cors',
    })
      .then(res => res.json())
      .then(text => {
        console.warn('text', text);

        window.open(url, '_blank');
      })
      .catch(err => {
        console.warn('Error', err);
      });
  };

Also see this answer.

about 4 years ago · Juan Pablo Isaza Denunciar
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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda