mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-08 06:38:46 +00:00
13 lines
290 B
JavaScript
13 lines
290 B
JavaScript
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;
|
|
}
|