From 6d890304a226249d0b6eadd46360aeadfa669694 Mon Sep 17 00:00:00 2001 From: Zynh0722 Date: Tue, 2 Apr 2024 23:59:41 -0700 Subject: [PATCH] matching urls to descriptions --- index.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/index.ts b/index.ts index eee0a97..4b85497 100644 --- a/index.ts +++ b/index.ts @@ -38,15 +38,21 @@ async function getPatchHrefs() { const allPatches = await getPatchHrefs(); -const patchRequests = allPatches.map((testPatchUrl) => +const patchRequests = allPatches.map((url) => (async () => { - const req = await fetch(testPatchUrl); + const req = await fetch(url); const data = parse(await req.text()); - return data.getElementsByTagName("h1")[0].nextElementSibling?.innerText; + return { + url, + description: + data.getElementsByTagName("h1")[0].nextElementSibling?.innerText, + }; })(), ); const dirtyPatchDescriptions = await Promise.all(patchRequests); -const patchDescriptions = dirtyPatchDescriptions.filter((e) => e) as string[]; +const patchDescriptions = dirtyPatchDescriptions.filter( + ({ description }) => description, +) as { url: string; description: string }[]; console.log(patchDescriptions);