aboutsummaryrefslogtreecommitdiff
path: root/src/app/web-series/components/data-fetch.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/web-series/components/data-fetch.js')
-rw-r--r--src/app/web-series/components/data-fetch.js87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/app/web-series/components/data-fetch.js b/src/app/web-series/components/data-fetch.js
new file mode 100644
index 0000000..e0feca5
--- /dev/null
+++ b/src/app/web-series/components/data-fetch.js
@@ -0,0 +1,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);
+ }
+};