Skip to content

Commit

Permalink
only save response in cache if there is no error
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgeiss0702 committed Jan 5, 2024
1 parent 5bb2750 commit 89c31e9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/routes/api/(live-statuses)/floatplane/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const GET = (async ({fetch, url, platform}) => {
if(!cache.lastData && r) {
cache = {
lastFetch: Date.now(),
lastData: r
lastData: typeof r["error"] == "undefined" ? r : cache.lastData
}
}

Expand All @@ -42,7 +42,8 @@ export const GET = (async ({fetch, url, platform}) => {
.catch(error => {
// retry in 30 seconds
cache = {
lastFetch: Date.now() - cache_time + 30e3
lastFetch: Date.now() - cache_time + 30e3,
lastData: cache.lastData
}
console.error("Error while fetching fp live status from thewandb:", error);
return false;
Expand All @@ -68,7 +69,7 @@ export const GET = (async ({fetch, url, platform}) => {
}
cache = {
lastFetch: Date.now(),
lastData: response
lastData: typeof response["error"] == "undefined" ? response : cache.lastData
}
if(!response.isWAN) {
response.isWAN = response.wan;
Expand Down

0 comments on commit 89c31e9

Please sign in to comment.