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