Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

126
Visualizações
How to manage dependents async await in ReactJS?

I'm still new to ReactJS and I'm having trouble doing an asyn await with dependencies from another request on axios.

I need to get a list of pokemon, this list returns me the name of pokemons.

With this list of names, I need to make another request, where I will pass this name that I received as a parameter.

In addition to passing the name as a parameter, I need to make a call with axios.get() using .map(). Because there are several calls I need to make. It is possible?

However, I am not able to do that. Can you tell me what I'm doing wrong?

Here's my code I put into codesandbox.io

import React from "react";
import axios from "axios";
import "./styles.css";

const App = () => {
  const BASE_URL = "https://pokeapi.co/api/v2";

  const getAllPokemons = async () => {
    const { data } = await axios.get(`${BASE_URL}/pokemon`);

    // Here is my pokemon list
    console.log(data);

    data.results.map((poke) => getPokeType(poke));
  };

  const getPokeType = async (poke) => {
    const { data } = await axios.get(`${BASE_URL}/type/${poke.name}`);

    console.log("data: ", data);
  };

  React.useEffect(() => {
    getAllPokemons();
  }, []);

  return (
    <div className="App">
      <h1>Hello CodeSandbox</h1>
      <h2>Start editing to see some magic happen!</h2>
    </div>
  );
};

export default App;

enter image description here

Thank you very much in advance.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda