Angular / TypeScript - Call a function after another one has been completed Angular / TypeScript - Call a function after another one has been completed typescript typescript

Angular / TypeScript - Call a function after another one has been completed


So remove the setTimeout part. It will call resolve or reject and then pass the execution to the next then or catch handler. If you have some asynchronous call in the Promise, you need to call resolve/reject in the result of that call.

What about not waiting 1500ms - the given time is actually the lowest time after which the function may be called. Maybe after 2000ms This is related to the main thread in which JS code works. If main thread has no work to done, then the results of the asynchronous calls are going to be executed.

function f1() {    return new Promise((resolve, reject) => {        console.log('f1');        resolve();    });}function f2() {   console.log('f2');}f1().then(res => f2());