What's the right strategy to using nested promises to write clean code? One of the ideas behind using promises is to get rid of nested callbacks aka callback hell. Even when using promises, nesting seems to be unavoidable sometimes:
User.find({hande: 'maxpane'})
.then((user) => {
Video.find({handle: user.handle})
.then((videos) => {
Comment.find({videoId: videos[0].id})
.then((commentThead) => {
//do some processing with commentThread, vidoes and user
})
})
})
Is there a way to get rid of the nesting and make the code more "linear". As it is, this code doesn't look very different from code that uses callbacks.