Skip to content

Commit

Permalink
fix(animegarden): handle detail resp failed
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Jan 16, 2024
1 parent e409d28 commit 26a2fce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 8 additions & 4 deletions packages/animegarden/src/garden/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,14 @@ export async function fetchResourceDetail(
const { baseURL = DefaultBaseURL, retry = 1 } = options;
const url = new URL(`detail/${provider}/${href}`, baseURL);

const resp = await retryFn(
() => fetch(url.toString(), { signal: options.signal }).then((r) => r.json()),
retry
);
const resp = await retryFn(async () => {
const resp = await fetch(url.toString(), { signal: options.signal });
if (resp.ok) {
return await resp.json();
} else {
throw new Error(`Fetch failed`, { cause: resp });
}
}, retry);

if (resp.id !== undefined && resp.detail !== undefined) {
return { id: resp.id, ...resp.detail };
Expand Down
2 changes: 0 additions & 2 deletions packages/app/src/pages/detail/[provider]/[href].astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
import { APP_HOST } from '~build/meta';
import { parse } from 'anitomy';
import { formatInTimeZone } from 'date-fns-tz';
Expand Down

0 comments on commit 26a2fce

Please sign in to comment.