Looking to understand the .then concept in JavaScript, I am curious if it is feasible to generate a series of .then
's using a for loop.
request.send(myRequest)
.then(r => console.log(r, 0))
.then(r => console.log(r, 1))
.then(r => console.log(r, 2))
.then(r => console.log(r, 3))
.then(r => console.log(r, 4))
Instead of manually adding each .then
, I am interested in dynamically creating a chain of .then
's so that I can execute .then
an incremental number of times using i++
.
Indeed, it is possible.