Skip to content

Commit

Permalink
fix(events): do not fail array of promises if one fails (#89)
Browse files Browse the repository at this point in the history
* fix(events): do not fail array of promises if one fails

* fix(events): return res data
  • Loading branch information
jtrein authored Sep 18, 2023
1 parent 0e70219 commit 28b3264
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions server/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,17 @@ const getSubscribersFromFile = async (): Promise<Subscribers> => {
};

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;
}
}
Expand Down

0 comments on commit 28b3264

Please sign in to comment.