diff options
Diffstat (limited to 'src/app/movies/components/requestsHandler.js')
| -rw-r--r-- | src/app/movies/components/requestsHandler.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/app/movies/components/requestsHandler.js b/src/app/movies/components/requestsHandler.js new file mode 100644 index 0000000..5f4db8b --- /dev/null +++ b/src/app/movies/components/requestsHandler.js @@ -0,0 +1,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; +}; |