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?