Created
March 2, 2017 19:58
-
-
Save Sharp6/9cb6b15e9e6df870d82baf81300fe130 to your computer and use it in GitHub Desktop.
Recursive async
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
var request = require('request'); | |
var doCallWithRecover = function() { | |
return new Promise(function(resolve, reject) { | |
request('https://pdbss.herokuapp.com', function(err,data) { | |
if(checkIfOk(data)) { | |
resolve(data); | |
} else { | |
return doCallWithRecover(); | |
} | |
}) | |
}); | |
}; | |
var checkIfOk = function(something) { | |
return false; | |
} | |
doCallWithRecover() | |
.then(data => console.log(JSON.parse(data.body))) | |
.catch(err => { console.log(err) }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment