untitled notebook

node v4.8.4
version: 1.0.0
endpointsharetweet
function createStudent(i){ return new Promise(function(resolve, reject){ setTimeout(function(){ //console.log(`creating student : ${i}`) resolve({student_created:i}) }) }) } var p= Promise.resolve(); for(let i = 1; i <= 3; ++i){ p = p.then(x=>{ console.log(`x: ${JSON.stringify(x)}`) return createStudent(i);}) } p = p.then(x=>{ console.log(`x: ${JSON.stringify(x)}`) }) console.log("done")
Loading…

no comments

    sign in to comment