Join Alexander Zanfir for an in-depth discussion in this video Dealing with nested callbacks, part of Up and Running with Node.js.
- Let's take a closer look at what…the nested callback issue really is.…To follow along you can open up…nested-callback-demo.js from the exercise files.…I would like to point out that this is not executable code.…This is only pseudo code to demonstrate the issue.…As we can see at the start,…we have four objects.…And each of these objects has a function…that takes a callback as one of its parameters.…And therefore we begin to chain the calls…to these objects within the callbacks.…We end up with something that's very unpleasant…and confusing to look at.…
This is a very common problem when…dealing with asynchronous code and node.…And there are several solutions to it.…One of them is promises.…Let's scroll down and see how promises…solve the nested callback issue.…As you can see in the solution,…all the callbacks are chained…using the then function…that wraps the next callback, and so on.…In the next video,…we will take a look at a library…which allows us to apply this type of solution.…
- Installing Node.js
- Writing modules and packages
- Reading and writing files
- Working with frameworks: Express, Sails, and Koa
- Generating promises
- Working with generator functions
Skill Level Beginner
Q: When I try to install Bluebird/Express/Gulp/Sails/KOA using the Node Package Manager, it seems to install correctly in the terminal. But why doesn't my project folder change?
A: You need to make sure that you've navigated to your project folder in the terminal. For example, in this course Alexander is working from the C:\Dev\ folder both in Brackets and in the terminal.