Fetch API & Handling JSON Responses
What optimization technique is demonstrated here?
const cache = new Map();
async function fetchWithCache(url, options = {}) {
if (!options.bypassCache && cache.has(url)) {
return cache.get(url);
}
const response = await fetch(url, options);
const data = await response.json();
if (!options.bypassCache) {
cache.set(url, data);
}
return data;
}