Open ukind opened 6 years ago
Sample code:
const promise = new Promise(function(resol, reject) { setTimeout(function() { const randomInt = Math.floor(Math.random() * 10); resol(randomInt); }, 500); }); promise.then(function(promiseResult) { console.log('The result is: ', promiseResult); return new Promise(function(resolved, rejected) { setTimeout(function() { const secondRandomInt = Math.floor(Math.random() * 10); resolved(secondRandomInt); }, 3000); }).then(function(resultFromSecondPomise) { console.log('Result from second Promise: ', resultFromSecondPomise); }); });
Sample code: