From b31ed4141f8fb0afccb8ae59bdd3614806f0e656 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Mon, 11 Sep 2023 21:37:29 +0300 Subject: Avoids running the callback function on 404 --- src/js/arching-kaos-fetch.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/js/arching-kaos-fetch.js b/src/js/arching-kaos-fetch.js index a22f9de..a29a5ae 100644 --- a/src/js/arching-kaos-fetch.js +++ b/src/js/arching-kaos-fetch.js @@ -18,7 +18,11 @@ function archingKaosFetchJSON( url, callback, params ){ const request = new XMLHttpRequest(); request.addEventListener("load", ()=>{ var json = JSON.parse(request.response); - callback(json, params); + if(request.status !== 404){ + callback(json, params); + } else { + archingKaosLog(`ERROR ${request.status} while loading ${url}`); + } }); request.addEventListener("error", ()=>{ console.log("An error occured."); -- cgit v1.2.3