Skip to content

Instantly share code, notes, and snippets.

View Axighi's full-sized avatar
💭
Rampaging

Azriel Axighi

💭
Rampaging
View GitHub Profile
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