aboutsummaryrefslogtreecommitdiff
path: root/src/app/anime/components/cacher.js
blob: ae9b10bd920b1e1d9d59e9d2fa6a3cbc64f08422 (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 { anime_info, video_url } from "../data-fetch/request";

export async function preFetchAnimeInfo(data) {
	try {
		const fetchPromises = data.results.map(async (element) => {
			await anime_info(element.id);
		});

		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 video_url(element.id);
		});

		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);
	}
}