Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return cache.get(key);
}
// eslint-disable-next-line no-console
console.log("fetching", key);
const fn: FigmaFunction =
params === undefined
? mapTypeToFunction[requestType]
: mapTypeToFunctionWithParams[requestType];
try {
const { data } = await fn(id, { ...params });
// We just need to parse the response if it's for a file, otherwise we return the raw data
const processedData =
"document" in data && requestType === RequestType.File ? processFile(data, id) : data;
// Only store data that doesn't change depending on the params
// We store it even if noCache is true so we can update the cache
if (params === undefined) {
cache.set(key, processedData);
}
return processedData as T;
} catch (e) {
throw new Error(e);
}
}