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

105
Views
Fetch returning undefined when specifing parameter on method GET

I'm working with javascript to return the username of users that are on a API and I can make it return something like this:

{"status":200,"users":[{"ID":2,"CreatedAt":"2022-04-24T16:17:41.615941Z","UpdatedAt":"2022-04-24T16:17:41.615941Z","DeletedAt":null,"alertTime":1,"sos":false,"username":"Jarret","access_mode":1,"UserFriends":null,"UserPositions":null},{"ID":3,"CreatedAt":"2022-04-24T16:17:44.203433Z","UpdatedAt":"2022-04-24T16:17:44.203433Z","DeletedAt":null,"alertTime":1,"sos":false,"username":"Narciso","access_mode":1,"UserFriends":null,"UserPositions":null},

And I want to return only the parameter called username but it always return me undefined and I can't figure out why

Here's my code:

function showUsers() {
  var myHeaders = new Headers();
  myHeaders.append("Authorization", token);

  var formdata = new FormData();

  var requestOptions = {
    method: "GET",
    headers: myHeaders,
    data: formdata,
    redirect: "follow",
  };

  fetch("https://api.secureme.pt/api/v1/user/", requestOptions)
    .then((response) => response.json())
     //SPECIFING HERE VVVVV
    .then((result) => document.getElementById("utilizadores").innerHTML = result.username)
    .catch((error) => console.log("error", error));
}
about 4 years ago · Juan Pablo Isaza
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!