I have simple demo to understand Promise concept but it is not working as expected, see my code which i have tried.
module.exports = async function (context, iotHubMessage) {
context.log('START');
var promise1 = new Promise(function (resolve, reject) {
setTimeout(function () {
resolve('foo');
}, 1000);
});
context.log(promise1);
promise1.then(function (resolve) {
context.log(resolve);
// expected output: "foo"
});
};
and I am geting this output
2019-01-24T12:58:38.695 [Information] START
2019-01-24T12:58:38.695 [Information] Promise { <pending> }
2019-01-24T12:58:38.696 [Information] Executed
why am not getting foo
at output log please help me thanks!