Dealing with nested callbacks

- 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.…

Resume Transcript Auto-Scroll

Author

Released

6/2/2015

If you've worked with JavaScript, you can quickly get up and running with Node.js, a lightweight and efficient platform for building network apps. Alexander Zanfir helps you write your first pieces of code and understand the frameworks available for the platform, including options such as Express, Sails, and Koa. He'll also help you create promises and generators, two unique aspects of Node.js. All this information is bundled into a small user authentication API Alexander creates along the way, which can be used as the stepping stone for the next full-scale app you build with Node.js.

Topics include:

Installing Node.js

Understanding the benefits of JavaScript

Writing modules and packages

Reading and writing files

Working with frameworks: Express, Sails, and Koa

Generating promises

Working with generator functions

Skill Level Beginner

57m 40s

Duration

515,447

Views

Show MoreShow Less

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.