Skip to content

Instantly share code, notes, and snippets.

Created August 29, 2017 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/c259bd5ff0044df19a523b25189ce6e8 to your computer and use it in GitHub Desktop.
Save anonymous/c259bd5ff0044df19a523b25189ce6e8 to your computer and use it in GitHub Desktop.
waitUntil created by leodotng - https://repl.it/K6U9/1
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);
}, num);
});
return promise;
}
waitUntil(2000, 'hello')
.then(function(res) {
console.log(res);
return waitUntil(1000, 'world');
})
.then(function(res) {
console.log(res);
return waitUntil(55, '!');
})
.then(function(res) {
console.log(res);
});
//Making calls to weather api, waiting for weather data from other website.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment