Created
August 29, 2017 20:13
-
-
Save anonymous/c259bd5ff0044df19a523b25189ce6e8 to your computer and use it in GitHub Desktop.
waitUntil created by leodotng - https://repl.it/K6U9/1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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