From 1ef347ab27de4a86c4e4607ebde67a5c0d82ce46 Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Mon, 30 Nov 2020 14:01:16 +0100 Subject: [PATCH] Use promise.all for multiple promise --- app/index.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/index.js b/app/index.js index 601f6ef..73023d0 100644 --- a/app/index.js +++ b/app/index.js @@ -224,12 +224,7 @@ module.exports.getLatestUpdates = async function(args, limit) { const urls = await latestFetch.fetchLatest(query, limit); // Get the gamedata from urls - const gameInfoList = []; - for(const url of urls) { - const gameinfo = await exports.getGameDataFromURL(url); - gameInfoList.push(gameinfo); - } - - return gameInfoList; + const promiseList = urls.map(u => exports.getGameDataFromURL(u)); + return await Promise.all(promiseList); }; //#endregion