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

335
Vistas
Access to object info using the pokeapi JAVASCRIPT

Hey I'm just trying to do the typical pokedex using the pokeapi API with vanilla javascript I'm just returning each pokemon information into an object and it's working, but I don't know how to access the property of the objects I'm trying to access the array but it returns me undefined I don't know how to print each Pokemon name on the console.

This how I'm fetching the info:

let pokemonarray = []
const getPokemonAxios = async () => {
  for (let i = 1; i <= 5 ; i++) {
    try {
      const res = await axios(`https://pokeapi.co/api/v2/pokemon/${i}`);
      const pokemon = res.data;
      pokemonarray.push({ ...pokemon }) 

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

const poke = getPokemonAxios()

console.log(pokemonarray)

This what shows on console when I print pokemonarray I don't know how to console.log elements like name or type on this object. pokeapi result

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

pokemonarray is an iterable so you can loop through the array using a forEach loop and then access and log the properties that are of interest to you

pokemonarray.forEach((pokemon) => {
    console.log(pokemon.name)
    })

this will log the name of each pokemon

about 4 years ago · Juan Pablo Isaza Denunciar
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