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

444
Vistas
API Integration - How to GET data from API and create a list using Javascript?

I need a quick help with (REST) API integration. I am trying to GET data from SWAPI (Star Wars API) which is an open API and put those data into the system. This is code that I have written so far.

(async () => {
  try {

    const PlanetDetails = await api.makeRequest({
      method: 'GET',
      url: 'https://swapi.dev/api/people/1',
    });

    var Name = PlanetDetails.data.name;
    var Vehicle = PlanetDetails.data.vehicle;
    var Species = PlanetDetails.data.species;
    var EyeColorr = PlanetDetails.data.eye_color;

    api.setVariable('Name', Name);
    api.setVariable('Vehicle', Vehicle);
    api.setVariable('Species', Species);
    api.setVariable('EyeColor', EyeColorr);

  } catch (error) {
    console.log(error)
  }
})();

The problem is that I can get only specific person's data using the ID as you can see in the URL. But I want all the planets name into a list. So I wrote the following code:

const PlanetDetails = await api.makeRequest({
      method: 'GET',
      url: 'https://swapi.dev/api/planets',
    });

But I am not sure how do I get the Name (attribute) and put it into a list/array.

Any help will be highly appreciated!

Thanks

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