diff options
| author | real-zephex <[email protected]> | 2024-05-14 01:02:50 +0530 |
|---|---|---|
| committer | real-zephex <[email protected]> | 2024-05-14 01:02:50 +0530 |
| commit | c0e1e1a5ab734d254392e8bfcc7ace0e0ff3b6fa (patch) | |
| tree | 271228b9cf8ba5bd80a79145216c84ee1144457d /src/app/anime/components/cacher.js | |
| parent | minor changes to the kdrama page (diff) | |
| parent | Merge pull request #27 from real-zephex/improvement-2 (diff) | |
| download | dramalama-c0e1e1a5ab734d254392e8bfcc7ace0e0ff3b6fa.tar.xz dramalama-c0e1e1a5ab734d254392e8bfcc7ace0e0ff3b6fa.zip | |
Merge branch 'master' of https://github.com/real-zephex/Dramalama-Next
Diffstat (limited to 'src/app/anime/components/cacher.js')
| -rw-r--r-- | src/app/anime/components/cacher.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/app/anime/components/cacher.js b/src/app/anime/components/cacher.js new file mode 100644 index 0000000..d3008fa --- /dev/null +++ b/src/app/anime/components/cacher.js @@ -0,0 +1,29 @@ +"use server"; + +import { info_url, watch_url } from "../../../../utils/anime_urls"; + +export async function preFetchAnimeInfo(data) { + try { + const fetchPromises = data.results.map(async (element) => { + await fetch(info_url(element.id), { next: { revalidate: 21600 } }); + }); + + await Promise.all(fetchPromises); + console.log("Anime info pre-fetched successfully!"); + } catch (error) { + console.error("Error occurred while pre-fetching anime info: ", error); + } +} + +export async function preFetchVideoLinks(data) { + try { + const fetchPromises = data.map(async (element) => { + await fetch(watch_url(element.id), { next: { revalidate: 21600 } }); + }); + + await Promise.all(fetchPromises); + console.log("Anime video links info pre-fetched successfully!"); + } catch (error) { + console.error("Error occurred while pre-fetching anime info: ", error); + } +} |