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

338
Views
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 answers
Answer question

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 Report
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!