blob: 934fdd69c6bb1ea84921ef77b5dceef8e2ee1100 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
// This function pre-fetches all the video links for a drama in the background
"use server";
export default async function PreFetchVideoLinks(data, dramaId) {
try {
const fetchPromises = data.map(async (element) => {
const link = `https://consumet-api-di2e.onrender.com/movies/dramacool/watch?episodeId=${element.id}&mediaId=${dramaId}`;
await fetch(link, { cache: "force-cache" });
});
await Promise.all(fetchPromises);
console.log("Video links pre-fetched successfully!");
} catch (error) {
console.error("Error occurred while pre-fetching video links:", error);
}
}
|