I am using pokeapi and I am creating a object inside a promise for every pokemon but I have to get the information that is in .species and is in another URL so I am calling another fetch but doesn´t give me the data.
const fetchPokemon = () => {
const promises = [];
for (let index = 1; index <= 150; index++) {
const url = `https://pokeapi.co/api/v2/pokemon/${index}`;
promises.push(fetch(url).then((res) => res.json()));
}
Promise.all(promises).then((results) => {
const pokemon = results.map((data) => ({
name: data.name,
egg_groups: getEgg(data)
}));
And the method that I am calling in egg_groups is like this:
return fetch(data.species.url).then((response) => response.json()).then(
(res)=> res.egg_groups.map((egg_group) => egg_group.name).join(" and "));
How I can get the "monster and plant" rather than the entire promise?