From a609dcef99e20ca9f4496eb77c0bf408378471a1 Mon Sep 17 00:00:00 2001 From: slonkazoid Date: Thu, 7 Mar 2024 18:04:44 +0300 Subject: [PATCH] i couldnt care less --- index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index c5c05cf..528dbaf 100644 --- a/index.js +++ b/index.js @@ -23,9 +23,19 @@ app.get("/*/status/*", async (req, res) => { let target = config.FUCKING_ENDPOINT + encodeURIComponent(config.TWITTER_BASE_URL + req.url.slice(1)); - let twitter_res = await fetch(target); + let twitter_res; + try { + twitter_res = await fetch(target); + } catch (err) { + returnres.status(502).send(err.message); + } if (twitter_res.status == 200) { - let body = await twitter_res.json(); + let body; + try { + body = await twitter_res.json(); + } catch (err) { + return res.status(502).send(err.message); + } let html = parse(body.html); let block = html.firstChild; let content = block.childNodes[0].innerText;