refactor: use custom axios instance and add try/catch

This commit is contained in:
Derrick Hammer 2023-12-17 18:01:04 -05:00
parent 4f4cebb721
commit 6604fdfad2
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 9 additions and 4 deletions

View File

@ -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", {
try {
httpClient.post("/api/events/siteUpdateReceived", {
cid: cid.toString(),
site: siteName,
});
} catch {}
});
}