From 6604fdfad219f848994e5b5abc013be9d4625e75 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 17 Dec 2023 18:01:04 -0500 Subject: [PATCH] refactor: use custom axios instance and add try/catch --- bridge.mts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bridge.mts b/bridge.mts index 8dbdbf4..40a1f61 100644 --- a/bridge.mts +++ b/bridge.mts @@ -14,6 +14,9 @@ const sites = JSON.parse( ) as SiteList; const client = new S5Client("https://s5.web3portal.com"); +const httpClient = axios.create({ + baseURL: "http://localhost", +}); for (const siteName in sites) { const site = sites[siteName]; @@ -22,9 +25,11 @@ for (const siteName in sites) { sub.listen((entry) => { const cid = CID.fromRegistry(entry.data); - axios.post("http://localhost/api/events/siteUpdateReceived", { - cid: cid.toString(), - site: siteName, - }); + try { + httpClient.post("/api/events/siteUpdateReceived", { + cid: cid.toString(), + site: siteName, + }); + } catch {} }); }