This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cachedFetch = (url, options) => { | |
let expiry = 5 * 60 // 5 min default | |
if (typeof options === 'number') { | |
expiry = options | |
options = undefined | |
} else if (typeof options === 'object') { | |
// I hope you didn't set it to 0 seconds | |
expiry = options.seconds || expiry | |
} | |
// Use the URL as the cache key to sessionStorage |
NewerOlder