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

251
Views
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 answers
Answer question

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 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!