From 764f90577eeadd653f3f6248fbf2b0918c97a3d5 Mon Sep 17 00:00:00 2001 From: "Alex Pooley (@zuedev)" Date: Tue, 21 Jul 2026 17:01:54 +0100 Subject: fix oncall w/ pocketbase controller --- 174bg/discord-bot/utilities/getUrl.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to '174bg/discord-bot/utilities/getUrl.js') 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(); }; -- cgit v1.2.3