Skip to content

Instantly share code, notes, and snippets.

@sergueyarellano
Created December 18, 2020 20:22
Show Gist options
  • Save sergueyarellano/9edd8dff801a4f09f007d8768cccd93f to your computer and use it in GitHub Desktop.
Save sergueyarellano/9edd8dff801a4f09f007d8768cccd93f to your computer and use it in GitHub Desktop.
async function * retryQuery () {
// calculate current day and pass it to query
const daysOfWeek = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
const currentDay = new Date().getDay()
const dayName = daysOfWeek[currentDay]
let result = await getRemindersForDay(dayName)
// if LastEvaluatedKey is found, query again, and again and again
// it means the response is paginated
while (result.LastEvaluatedKey) {
yield result
result = await getRemindersForDay(dayName, result.LastEvaluatedKey).catch()
}
yield result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment