Join Alexander Zanfir for an in-depth discussion in this video Creating an endpoint with Express, part of Learning Node.js.
- Now that we know how to serve static content with Express,…let's take a look at serving some dynamic content.…We'll create an endpoint which allows us to access…a specific resource, or a specific action of a resource,…such as writing, reading, etc.…Let's create our new file.…We'll call this "express-endpoint-demo.js".…And we can go over to our first file…and grab the express setup we used earlier.…And I"ll just grab the entire file for now.…
And we no longer need the "express.static",…so we can take that out and it'll save us a bit of time.…And we're still going to use "app.use",…but instead of serving static content,…we'll set up our endpoint.…We'll call it "message", so that when we go into our browser…at the following address and we type in "/message",…we'll see the following resource served.…So let's go back and continue setting that up.…For the second parameter, we'll specify the callback.…And the callback is actually middleware.…
And every middleware inside Express…has a request and response.…So we'll pass in those as the first and second parameter.…
- 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.