I want to create some code that executes sequentially as follows:
console.log('Called before the function containing a promise');
var result = getSomeData();
console.log('Called after getSomeData() has completed fully');
getSomeData() {
var stuff = <do something here>;
return dbGetDocument(stuff).then((result)=>{
return result;
});
}
dbGetDocument() is an existing library function (written by someone else) that returns a promise.
When running this code the final console.log
gets executed before the dbGetDocument.then
has returned it's result.