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

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