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 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue