aboutsummaryrefslogtreecommitdiff
path: root/src/app/anime/data-fetch/request.js
blob: 579f69313c77d838d76d744b4a41d31df8cf5f89 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"use server";

import {
	popular_url,
	recent_epsiodes_url,
	top_airing_url,
	search_url,
	info_url,
	watch_url,
} from "../../../../utils/anime_urls";

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

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

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

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

export const anime_info = async (id) => {
	const res = await fetch(info_url(id), {
		next: { revalidate: 21600 },
	});
	const data = await res.json();
	return data;
};

export const video_url = async (episodeId) => {
	const res = await fetch(watch_url(episodeId), {
		cache: "force-cache",
	});
	const data = await res.json();
	return data;
};