fix: refactor episode retrieval to support pagination and sort episodes by title

This commit is contained in:
himanshu8443
2025-07-09 15:23:24 +05:30
parent 73d248a662
commit 0ab8e300fb
4 changed files with 68 additions and 38 deletions

View File

@@ -34,7 +34,6 @@ export const getEpisodes = async function ({
},
});
const data = res.data;
console.log("nfEpisodes", data);
data?.episodes?.map((episode: any) => {
episodeList.push({
@@ -49,7 +48,11 @@ export const getEpisodes = async function ({
}
}
return episodeList;
return episodeList.sort((a, b) => {
const aNum = parseInt(a.title.replace("Episode ", ""));
const bNum = parseInt(b.title.replace("Episode ", ""));
return aNum - bNum;
});
} catch (err) {
console.error("nfGetEpisodes error", err);
return [];