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

378
Vistas
React, Axios, PokeAPI: undefined reading Map

To improve my React skills I was following this tutorial to how create a list of name using PokeAPI.

I am stopped at 11.35, because I put this code as the tutorial show (the first block is from App.js, the second is from a component call PokemonList.js) :

function App() {
  const [pokemon, setPokemon] = useState([])

  useEffect(()=>{

    axios.get("https://pokeapi.co/api/v2/pokemon").then(res=> {
      setPokemon(res.data.result.map(p => p.name))
    })
  }, [])
  
   return (
    <PokemonList pokemon={pokemon}/>
  );
}

export default App;

  
    

export default function PokemonList({pokemon}){
    return (
        <div>
            {pokemon.map(p => (
                <div key={p}>{p}</div>
            ))}
        </div>
    )
}

But in the console I have the error message: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'map')

I have understand that I need to put a Promise.all in App.js (I found a similar question before to asking) but I have not clear how I must change in the PokemonList component to print the list on screen.

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

0

There is a typo. You have to change from result to results.

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