I used to code like this, and eventually found myself in a callback hell.
Redis.get("boo", (res1) => {
Redis.get(res1, (res2) => {
console.log(res1);
console.log(res2);
});
});
Howeever, when I do it like this:
Redis.getAsync("boo)
.then(res1 => {
return Redis.getAsync(res1);
})
.then(res2 => {
console.log(res1) // undefined
});
I cannot access res1
any longer. Passing parameters on each return feels dirty.
Any elegant solutions to this issue?