refactor: do title conversion server side

This commit is contained in:
2024-10-27 09:27:27 -04:00
parent 2ec61b7332
commit 99963083f0
2 changed files with 14 additions and 7 deletions

View File

@@ -41,7 +41,18 @@ export async function fetchSearchResultsFromAnilist(
}
const { media: results, pageInfo } = page;
return { results, hasNextPage: pageInfo?.hasNextPage };
return {
results: results?.map((result) => {
if (!result) return null;
return {
id: result.id,
title: result.title?.userPreferred ?? result.title?.english,
coverImage: result.coverImage,
};
}),
hasNextPage: pageInfo?.hasNextPage,
};
})
.catch((err) => {
const response = err.response;