diff options
| author | Alex Pooley (@zuedev) <zuedev@gmail.com> | 2026-07-21 17:01:54 +0100 |
|---|---|---|
| committer | Alex Pooley (@zuedev) <zuedev@gmail.com> | 2026-07-21 17:01:54 +0100 |
| commit | 764f90577eeadd653f3f6248fbf2b0918c97a3d5 (patch) | |
| tree | 84ca4a80cf0d230e0484bac40801e194691169bc /174bg/discord-bot/utilities | |
| parent | 55e8a329ce0cbb29c0f41c6c4c0187230975a011 (diff) | |
| download | unnamed-group-764f90577eeadd653f3f6248fbf2b0918c97a3d5.tar unnamed-group-764f90577eeadd653f3f6248fbf2b0918c97a3d5.tar.gz unnamed-group-764f90577eeadd653f3f6248fbf2b0918c97a3d5.tar.bz2 unnamed-group-764f90577eeadd653f3f6248fbf2b0918c97a3d5.tar.xz unnamed-group-764f90577eeadd653f3f6248fbf2b0918c97a3d5.zip | |
fix oncall w/ pocketbase controller
Diffstat (limited to '174bg/discord-bot/utilities')
| -rw-r--r-- | 174bg/discord-bot/utilities/getUrl.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/174bg/discord-bot/utilities/getUrl.js b/174bg/discord-bot/utilities/getUrl.js index 49342d9..a6e22ef 100644 --- a/174bg/discord-bot/utilities/getUrl.js +++ b/174bg/discord-bot/utilities/getUrl.js @@ -1,5 +1,14 @@ export default async (url) => { const response = await fetch(url); + if (!response.ok) return null; - return await response.json(); + + // is it json? + const contentType = response.headers.get("content-type"); + if (contentType && contentType.includes("application/json")) { + return await response.json(); + } + + // fallback to text + return await response.text(); }; |
