diff --git a/packages/animegarden/package.json b/packages/animegarden/package.json index eab7e9e0..687535b3 100644 --- a/packages/animegarden/package.json +++ b/packages/animegarden/package.json @@ -19,6 +19,7 @@ "license": "MIT", "author": "XLor", "sideEffects": false, + "type": "module", "exports": { ".": { "require": "./dist/index.cjs", diff --git a/packages/scraper/src/dmhy/index.ts b/packages/scraper/src/dmhy/index.ts index 467704b3..b8a59369 100644 --- a/packages/scraper/src/dmhy/index.ts +++ b/packages/scraper/src/dmhy/index.ts @@ -22,10 +22,13 @@ export async function fetchDmhyPage( ): Promise { const { page = 1, retry = 5 } = options; - const resp = await retryFn( - () => ofetch(`https://share.dmhy.org/topics/list/page/${page}`), - retry - ); + const resp = await retryFn(async () => { + const resp = await ofetch(`https://share.dmhy.org/topics/list/page/${page}`); + if (!resp.ok) { + throw new Error(resp.statusText, { cause: resp }); + } + return resp; + }, retry); if (!resp.ok) { throw new Error('Failed connecting https://share.dmhy.org'); }