From b7dafaf0892fb4a331e0ab59a832adf03cb1db86 Mon Sep 17 00:00:00 2001 From: Jonas_Jones <91549607+JonasunderscoreJones@users.noreply.github.com> Date: Sun, 28 Jan 2024 15:26:30 +0100 Subject: [PATCH] Changed error codes to default --- src/index.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/index.js b/src/index.js index c7ef22e..bc08b0a 100644 --- a/src/index.js +++ b/src/index.js @@ -27,21 +27,18 @@ addEventListener('fetch', event => { if (apiResponse.ok) { // If the API request is successful, return the response return apiResponse; - } else if (apiResponse.status === 502) { + } else if (apiResponse.status === 502 || apiResponse.status === 530) { // If the API request fails, return an error response - return new Response('API backend is down temporarily', { - status: 420, - statusText: 'API Backend Downtime Error' - }); - } else if (apiResponse.status === 530) { - // If the API request fails, return an error response - return new Response('API backend went down just now :( It should be back up in a matter of seconds!', { - status: 421, - statusText: 'API Backend Downtime Error' + return new Response('Service Unavailable', { + status: 503, + statusText: 'Service Unavailable' }); } else { - // If the API request fails, return the API response - return apiResponse; + // If the API request fails, return an error response + return new Response('API backend went down just now :( It should be back up in a matter of seconds!', { + status: apiResponse.status, + statusText: apiResponse.statusText + }); } } catch (error) { // If an error occurs during the API request, return an error response