aboutsummaryrefslogtreecommitdiff
path: root/src/app/movies/components/cacher.js
diff options
context:
space:
mode:
authorzephex-alt <[email protected]>2024-05-06 22:02:15 +0000
committerGitHub <[email protected]>2024-05-06 22:02:15 +0000
commitd58aa441e59f4f04f126c23da0864a5ff682e50a (patch)
treef772df95c9e29df62f25bc0a16e6cad78e2fd69e /src/app/movies/components/cacher.js
parentadded MOVIES support. SERIES support coming soon! (diff)
downloaddramalama-d58aa441e59f4f04f126c23da0864a5ff682e50a.tar.xz
dramalama-d58aa441e59f4f04f126c23da0864a5ff682e50a.zip
minor fixes
Diffstat (limited to 'src/app/movies/components/cacher.js')
-rw-r--r--src/app/movies/components/cacher.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/app/movies/components/cacher.js b/src/app/movies/components/cacher.js
new file mode 100644
index 0000000..169508a
--- /dev/null
+++ b/src/app/movies/components/cacher.js
@@ -0,0 +1,17 @@
+import { getInfoURL } from "../../../../utils/movie_urls";
+
+const PreFetchMovieInfo = async (data) => {
+ try {
+ const fetchPromises = data.results.map(async (element) => {
+ const link = `${getInfoURL(element.id)}`;
+ await fetch(link, { next: { revalidate: 21600 } });
+ });
+
+ await Promise.all(fetchPromises);
+ console.log("Movie info pre-fetched successfully!");
+ } catch (error) {
+ console.error("Error occurred while pre-fetching video links:", error);
+ }
+};
+
+export default PreFetchMovieInfo;