I need to do a promise sequence. I'd like to use a standards based approach (ES6?). What's the best way to achieve this? getToken()
and httpReq()
return promises, clock.now
simply returns the unix timestamp of now. My code looks something like below now (simplified/condensed). I understand I need to flatten the promise chain with a single catch... Can someone illustrate a clean, readable, non-clever, ES6 way?
// we don't have a good token so we need to get one first, then GET the resource.
getToken(host, port, auth).then(function(token) {
httpReq(method, host, port, path, token).then(function(data) {
console.log(data);
}, function(status) {
console.log(status);
});
}, function(status) {
console.log(status);
});