From 4aa89b66da01cb690e8b14dd23eb243791364c8c Mon Sep 17 00:00:00 2001 From: Erki Aas Date: Tue, 13 Dec 2022 14:05:08 +0200 Subject: [PATCH] Fix unstable behaviour --- index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index 64c5834..4d436a2 100644 --- a/index.ts +++ b/index.ts @@ -24,7 +24,7 @@ const signer = async function (asset: string) { return await presigner.presign(new HttpRequest(s3ObjectUrl)); } -const getPromises = async function (resp: object, path: string): Promise { +const getScreenshots = async function (resp: object, path: string): Promise { const screenshots = resp.screenshots ? resp.screenshots : [] if (path === '/details/') { return screenshots.map(async (x) => { @@ -47,8 +47,8 @@ export default { async fetch(request: Request) { let reqUrl = await parseUrl(request.url) let req = await request.json(); - - return Promise.all(await getPromises(req, reqUrl.path)).then((r) => { + let promises = getScreenshots(req, reqUrl.path) + return Promise.all(promises).then((r) => { let resp = Object.assign({}, req) resp.screenshots = r return resp