Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slmyers/6ed98476a0eac71c76117e2b2275eaf2 to your computer and use it in GitHub Desktop.
Save slmyers/6ed98476a0eac71c76117e2b2275eaf2 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