aboutsummaryrefslogtreecommitdiff
path: root/src/app/movies/components/cacher.js
blob: 169508ae8a4d431a278ce1246e191c8026e71f5a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { getInfoURL } from "../../../../utils/movie_urls";

const PreFetchMovieInfo = async (data) => {
	try {
		const fetchPromises = data.results.map(async (element) => {
			const link = `${getInfoURL(element.id)}`;
			await fetch(link, { next: { revalidate: 21600 } });
		});

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

export default PreFetchMovieInfo;