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

94
Vistas
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
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