Implement withCache(fetch, ttl)
A cache-aside wrapper. Write withCache(fetch, ttl) that returns a function (url) => Promise<data>: the first call for a url fetches and parses JSON, then caches it; any call for the same url within ttl milliseconds returns the cached data without calling fetch again. After ttl has elapsed, the next call fetches fresh data.
const cached = withCache(fetch, 60000);
await cached("/config"); // hits the network
await cached("/config"); // cache hit, no network call