Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

255
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda