diff options
| author | real-zephex <[email protected]> | 2024-05-19 21:38:18 +0530 |
|---|---|---|
| committer | real-zephex <[email protected]> | 2024-05-19 21:38:18 +0530 |
| commit | f936d0bc251b2e931d0729198da115b00f5a44a1 (patch) | |
| tree | 8ce79c53a479038725e905245c2975bed27fc69e /src/app/web-series/components/data-fetch.js | |
| parent | style(homepage): removed unnecessary sub text from the homepage cards and cha... (diff) | |
| parent | Merge pull request #28 from real-zephex/improvement-2 (diff) | |
| download | dramalama-f936d0bc251b2e931d0729198da115b00f5a44a1.tar.xz dramalama-f936d0bc251b2e931d0729198da115b00f5a44a1.zip | |
Merge branch 'master' of https://github.com/real-zephex/Dramalama-Next
Diffstat (limited to 'src/app/web-series/components/data-fetch.js')
| -rw-r--r-- | src/app/web-series/components/data-fetch.js | 87 |
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); + } +}; |