I'm trying to do this:
service.getConfig()
.then(cfg => service.getData())
.then(data => service.process(data,cfg))
.then(results => console.log(results))
.catch(err => console.log(err));
The obvious problem here is that cfg
goes out of scope in the second .then
block. There are many messy ways I can fix this, like by declaring cfg
in an outer scope, or passing cfg
through service.getData()
some how and returning [data,cfg]
. But is there a nice way to code this without loosing the beautiful concise elegance of chained promises and one-line arrow functions?