aboutsummaryrefslogtreecommitdiff
path: root/src/app/anime/components/cacher.js
blob: d3008fa12021049ed68b49bbe19f710ed04e67e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"use server";

import { info_url, watch_url } from "../../../../utils/anime_urls";

export async function preFetchAnimeInfo(data) {
	try {
		const fetchPromises = data.results.map(async (element) => {
			await fetch(info_url(element.id), { next: { revalidate: 21600 } });
		});

		await Promise.all(fetchPromises);
		console.log("Anime info pre-fetched successfully!");
	} catch (error) {
		console.error("Error occurred while pre-fetching anime info: ", error);
	}
}

export async function preFetchVideoLinks(data) {
	try {
		const fetchPromises = data.map(async (element) => {
			await fetch(watch_url(element.id), { next: { revalidate: 21600 } });
		});

		await Promise.all(fetchPromises);
		console.log("Anime video links info pre-fetched successfully!");
	} catch (error) {
		console.error("Error occurred while pre-fetching anime info: ", error);
	}
}