aboutsummaryrefslogtreecommitdiff
path: root/src/app/movies/components/requestsHandler.js
blob: 5f4db8b5a0b20833b6eef4df0225835d8ce5521f (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
30
31
32
33
34
35
36
"use server";

import {
	SEARCH,
	TRENDING,
	POPULAR,
	getInfoURL,
	TOP_RATED,
	NOW_IN_THEATERS,
	UPCOMING_MOVIES,
} from "../../../../utils/movie_urls";

export const SearchMovie = async (title) => {
	const res = await fetch(SEARCH(title), { next: { revalidate: 21600 } });
	const data = await res.json();
	return data;
};

export const MovieHomepageDataFetcher = async (type) => {
	const dataAvailable = {
		trending: TRENDING,
		popular: POPULAR,
		top: TOP_RATED,
	};
	const res = await fetch(dataAvailable[type], {
		next: { revalidate: 21600 },
	});
	const data = await res.json();
	return data;
};

export const MovieInfoData = async (id) => {
	const res = await fetch(getInfoURL(id), { cache: "force-cache" });
	const data = await res.json();
	return data;
};