fix: fetchFromMultipleSources returns errorOccurred only if all sources fail
This commit is contained in:
@@ -48,12 +48,12 @@ app.openapi(route, async (c) => {
|
||||
const aniListId = Number(c.req.query("id"));
|
||||
const aniListToken = c.req.header("X-AniList-Token");
|
||||
|
||||
const { result: title, errors } = await fetchFromMultipleSources([
|
||||
const { result: title, errorOccurred } = await fetchFromMultipleSources([
|
||||
() => fetchTitleFromAnilist(aniListId, aniListToken ?? undefined),
|
||||
() => fetchTitleFromAmvstrm(aniListId),
|
||||
]);
|
||||
|
||||
if (errors?.length > 0) {
|
||||
if (errorOccurred) {
|
||||
return c.json(ErrorResponse, { status: 500 });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user