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

254
Vistas
I want to fetch user information from index page using fetch
  1. After successful login, you will be directed to /index.
  2. Retrieve user information by using fetch with JavaScript within the index page.
  3. At this time, it moves to the url used for fetch, not to the index page. Why? I just want to apply the value of the object response from fetch to index.html.

This is the code in error

//index.html
<html>
 <head></head>
 <body>
  <div id='user'></div>
  <script src="./index.js"></script>
 </body>
</html>

//index.js
const id = document.getElementById('user');
fetch('/api/user')
.then((res)=>res.json)
.then((data)=>{
 id.innerText = data.userid})

When you access the index page, the corresponding screen appears.

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

0

The problem is probably in your redirection/login code, not what you posted here. If you post that, maybe we could help further.

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