mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-08 22:48:46 +00:00
utils cleanup, initial static generation
This commit is contained in:
parent
ec8700f3e9
commit
e1a3a82f75
86 changed files with 279 additions and 261 deletions
13
src/utils/proxy/cached-fetch.js
Normal file
13
src/utils/proxy/cached-fetch.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
import cache from "memory-cache";
|
||||
|
||||
export default async function cachedFetch(url, duration) {
|
||||
const cached = cache.get(url);
|
||||
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const data = await fetch(url).then((res) => res.json());
|
||||
cache.put(url, data, duration * 1000 * 60);
|
||||
return data;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue