Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ryanflorence/f4ea16304a04c9430ab9bfebac3e4a87 to your computer and use it in GitHub Desktop.
Save ryanflorence/f4ea16304a04c9430ab9bfebac3e4a87 to your computer and use it in GitHub Desktop.
const cache = {}
export default getJSONWithCache(url) {
return cache[url] ?
Promise.resolve(cache[url]) :
getJSON(url).then(json => {
cache[url] = json
return json
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment