I am trying to call functions call2() and then call3() in this order, so that call3() is called only when call2() terminates. I am using Promise to achieve that.
But call3() is called before call2() terminates. Here is my code:
function call2() { return new Promise(function (resolve, reject) { setTimeout(function () { console.log("calling 2"); resolve(true); }, 3000); }); } function call3() { console.log("calling 3"); } call2().then(call3()); I am obviously doing something wrong, or could not understand how to use promise. Any help please?