From 28b32641c864f170b537c6181220a8c22d6548a7 Mon Sep 17 00:00:00 2001 From: Jeremiah Naylor-Trein Date: Mon, 18 Sep 2023 16:36:01 +0100 Subject: [PATCH] fix(events): do not fail array of promises if one fails (#89) * fix(events): do not fail array of promises if one fails * fix(events): return res data --- server/events/index.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/events/index.ts b/server/events/index.ts index 5714c6cd..6bc19249 100644 --- a/server/events/index.ts +++ b/server/events/index.ts @@ -42,12 +42,17 @@ const getSubscribersFromFile = async (): Promise => { }; async function sendEvent(event, to) { - const res = await axios.post(to, event); - - // Attempt to get any JSON response try { - return await res; + const { data } = await axios.post(to, event); + + return data; } catch (error) { + // Attempt to print error from Axios + console.error( + `Failed to send event to ${to}`, + error.response ? error.repsonse.data : error.message + ); + return undefined; } }