-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Maybe it will be useful to not cache date if microFunction() throw an error
actual code
module.exports = (ms, microFunction) => async (req, res) => {
const lastCall = await retrieveData(req.url)
if (lastCall && lastCall.date > new Date()) {
return lastCall.data
}
const data = await microFunction(req, res)
const date = new Date(new Date().getTime() + ms)
saveData(req.url, { data, date })
return data
}
expected code
module.exports = (ms, microFunction) => async (req, res) => {
const lastCall = await retrieveData(req.url)
if (lastCall && lastCall.date > new Date()) {
return lastCall.data
}
try {
const data = await microFunction(req, res)
const date = new Date(new Date().getTime() + ms)
saveData(req.url, { data, date })
} catch (e){
console.error(e)
}
return data
}
Metadata
Metadata
Assignees
Labels
No labels