Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sample of how to do recursion using a promises
/**
* @param {Integer} devs
* @param {Array} elem
*/
let getSequences = (devs, elem) => {
return new Promise((resolve, reject) => {
if (devs === 0) {
resolve(elem)
return
}
devs--
getNextValueForSequence(fdb, 'ACTION_ID_SEQ')
.then((res) => {
elem.push(res)
getSequences(devs, elem)
.then(() => {
resolve(elem)
})
.catch((err) => {
reject(err)
})
})
.catch((err) => {
reject(err)
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.