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

85
Views
axios swapi api call on embedded url - return value

New to apis, and using the https://swapi.dev/ API.

On the https://swapi.dev/api/people I am trying to extract the "homeworld" property. It exisits as a URL.

But I really want the name of the planet to replace the URL.

[![eg:[1]][1] [1]: https://i.stack.imgur.com/oKWOb.gif

    const getPeople = async () => {
    try{
        //fetch data from api
        const res = await axios.get('https://swapi.dev/api/people')
        const pl = await axios.get('https://swapi.dev/api/planets/')
        //set People
        setPeople(res.data.results)
        setPlanet(pl.data.results)
        setLoading(true)
        // console.log(res.data.results)
        People.map((item)=>{console.log(item.name)})
        Planet.map((x) => {console.log(x.name)});
        Planet.map((y) => {console.log(y.residents)});
        // console.log(pl.data.results)
    } catch (err) {
        alert(err.message);
    }
}

how would I allow the planet item.name to replace the people item.homeland URL value?

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!