From 2b1ab96da5e1dbf8effee31fbf71563408ee094f Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Wed, 10 Mar 2021 12:22:12 +0100 Subject: [PATCH] CHange for with map --- src/example.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/example.ts b/src/example.ts index cde9c79..5fee7b7 100644 --- a/src/example.ts +++ b/src/example.ts @@ -90,7 +90,7 @@ async function main() { ); // Get game data - for (const gamename of gameList) { + gameList.map(async (gamename) => { console.log(`Searching '${gamename}'...`); // Prepare the query @@ -103,14 +103,11 @@ async function main() { const searchResult = await searchHandiwork(query, 1); // No game found - if (searchResult.length === 0) { - console.log(`No data found for '${gamename}'\n`); - continue; - } - - // Extract first game - const gamedata = searchResult.shift(); - const authors = gamedata.authors.map((a, idx) => a.name).join(", "); - console.log(`Found: ${gamedata.name} (${gamedata.version}) by ${authors}\n`); - } + if (searchResult.length !== 0) { + // Extract first game + const gamedata = searchResult.shift(); + const authors = gamedata.authors.map((a, idx) => a.name).join(", "); + console.log(`Found: ${gamedata.name} (${gamedata.version}) by ${authors}\n`); + } else console.log(`No data found for '${gamename}'\n`); + }); }