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

220
Vistas
Using Fetch to update a div with json from server

I'm creating a website in which the user can click buttons to retrieve information from the server which will then appear on the page.

Clicking on this button sends a request for the data. Looking at developer tools, I can see the request is successful however my code isn't doing anything with the response.

  
  let response = fetch('http://127.0.0.1:3000/dylan/list', { mode: 'no-cors' })
    .then(console.log("fetch sent"))
    //console.log(response))
    .then(response => {
      return response.text()
      console.log("response")
    }).then(text => {
       document.getElementById("folk").append(text)
       console.log("response2")})

"folk" is a list that I want the response data to be added to. I think theres probably something wrong at or after the 5th line. Any help would be appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This is how it should looks like

let response = fetch('http://127.0.0.1:3000/dylan/list', { mode: 'no-cors' })
.then(console.log("fetch sent"))
.then(response => {
  return response.text().then(text => {
    document.getElementById("folk").append(text)
  });
});

more details can be found on https://developer.mozilla.org/en-US/docs/Web/API/Response/text

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