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

149
Visualizações
why return "Promise { <pending> }" all the times?
exports.getNews = async (category) =>{ //get a promise from api for display it in mustach template

  exports.fetch_news_from_API =  async (category) => { // get data from api
    /* get data from api*/
    return data.articles; // promise
  }

  exports.getData = async (data) =>{ // add an id for every news
    let finalData = [];
    for(let i = 0; i < data.length; i++){
      let news = {
        id : i,
        title : data[i].title,  //api object
        author : data[i].author,
        description : data[i].description,
        publishedAt : data[i].publishedAt,
      }
      finalData.push(news);
    }
    return finalData; // news
  }
  
  let data = await this.fetch_news_from_API(category);
  let news = await this.getData(data);
  return news; // return pending all the time whene i use it in app.get
}

I would like to use "news" to display it but I can not because it returns all the time "pending" thank you in advance

about 4 years ago · Santiago Trujillo
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