Changed error codes to default

This commit is contained in:
Jonas_Jones 2024-01-28 15:26:30 +01:00
parent 5c36b3b283
commit b7dafaf089

View file

@ -27,21 +27,18 @@ addEventListener('fetch', event => {
if (apiResponse.ok) { if (apiResponse.ok) {
// If the API request is successful, return the response // If the API request is successful, return the response
return apiResponse; return apiResponse;
} else if (apiResponse.status === 502) { } else if (apiResponse.status === 502 || apiResponse.status === 530) {
// If the API request fails, return an error response // If the API request fails, return an error response
return new Response('API backend is down temporarily', { return new Response('Service Unavailable', {
status: 420, status: 503,
statusText: 'API Backend Downtime Error' statusText: 'Service Unavailable'
});
} 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'
}); });
} else { } else {
// If the API request fails, return the API response // If the API request fails, return an error response
return apiResponse; 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) { } catch (error) {
// If an error occurs during the API request, return an error response // If an error occurs during the API request, return an error response