mirror of
https://github.com/JonasunderscoreJones/api.jonasjones.dev.git
synced 2025-10-22 19:59:17 +02:00
Changed error codes to default
This commit is contained in:
parent
5c36b3b283
commit
b7dafaf089
1 changed files with 9 additions and 12 deletions
21
src/index.js
21
src/index.js
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue