aboutsummaryrefslogtreecommitdiff
path: root/src/app/web-series/components/data-fetch.js
blob: e0feca57e01767b80e25ce09f34a3d7f27ac39ca (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"use server";

import {
	popular_tv_shows,
	trending_tv_shows,
	top_rated_shows,
	recommended_shows,
	crew_details,
	tv_info,
	search_tv,
} from "../../../../utils/series_urls";

export const POPULAR_SHOWS = async () => {
	try {
		const res = await fetch(popular_tv_shows(), {
			next: {
				revalidate: 21600,
			},
		});
		const data = await res.json();
		return data;
	} catch (error) {
		throw new Error(error.message);
	}
};

export const TRENDING_SHOWS = async () => {
	try {
		const res = await fetch(trending_tv_shows(), {
			next: {
				revalidate: 21600,
			},
		});
		const data = await res.json();
		return data;
	} catch (error) {
		throw new Error(error.message);
	}
};

export const TOP_SHOWS = async () => {
	try {
		const res = await fetch(top_rated_shows(), {
			next: {
				revalidate: 21600,
			},
		});
		const data = await res.json();
		return data;
	} catch (error) {
		throw new Error(error.message);
	}
};

export const SERIES_INFO = async (id) => {
	try {
		const res = await fetch(tv_info(id), { next: { revalidate: 21600 } });
		const data = await res.json();
		return data;
	} catch (error) {
		throw new Error(error.message);
	}
};

export const CREW_DETAILS = async (id) => {
	try {
		const res = await fetch(crew_details(id), {
			next: { revalidate: 21600 },
		});
		const data = await res.json();
		return data;
	} catch (error) {
		throw new Error(error.message);
	}
};

export const SEARCH_TV = async (title) => {
	try {
		const res = await fetch(search_tv(title), {
			next: { revalidate: 21600 },
		});
		const data = await res.json();
		return data;
	} catch (error) {
		throw new Error(error.message);
	}
};