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

164
Visualizações
async Function returns Promise { <pending> },

so im trying to get some data to the client side, but it is arriving empty, since everytime i try to get the data returned from the fetch its giving Promise { }.

Also, this async map function is inside of another async function called default, if that helps.


async function default(){


const result = last10Matches.map(async (match) => {
      const matchurl = `https://api.pubg.com/shards/${playerPlatform}/matches/${match.id}`;
      const matchresponse = await fetch(matchurl, options);
      const matchdata = await matchresponse.json();

      matchdata.included.forEach((player) => {
        if (
          player.type == 'participant' &&
          player.attributes.stats.name == playerName
        ) {
          playerRecentStats.push({
            kills: player.attributes.stats.kills,
            dmgDone: player.attributes.stats.damageDealt,
            knocks: player.attributes.stats.DBNOs,
            date: matchdata.data.attributes.createdAt,
          });
        }
      });
      // console.log(playerRecentStats); // This does log the correct data here.

      return playerRecentStats;
    });

    console.log(result); // This here returns   Promise { <pending> }

/*
// i Also tried this below. with an empty result whatsoever.
async () => {
      console.log(await result);
    };
*/

}

Thanks 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