waituntil
function waitUntil(num, str) {
//inside here we'll do a standard set time document
var promise = new Promise(function(resolve, reject) {
setTimeout(function() {
resolve(str); //whatever function that is passend in
}, num);
});
return promise;
}
waitUntil(1000, 'Hey there')
.then(function(res) {
console.log(res);
return waitUntil(1000, 'My name');
})
.then(function(res) {
console.log(res);
return waitUntil(1000, 'is');
})
.then(function(res) {
console.log(res);
return waitUntil(1000, 'Josh');
})
.then(function(res) {
console.log(res);
return waitUntil(1000, 'Leong');
})
.then(function(res) {
console.log(res);
});
//Making calls to weather api, waiting for weather data from other website.