REST API in Express
Let's take a look at how we can implement REST API:s in Express.
json() is part of express
Nowadays, you can use express.json()
instead of bodyParser.json()
to create a middleware parsing the body of incoming HTTP requests in JSON format.
Lecture material
Recommended reading
If you already have much experience of using Express, then there is no recommended reading. If you think using Express is hard, then you can read:
- The book Express in Action: Writing, building, and testing Node.js applications (available on JU library online):
- Part 1.Intro
- Chapter 1. What is Express?
- Chapter 2. The basics of Node.js
- Chapter 3. Foundations of Express
- Part 2.Core
- Chapter 4. Middleware
- Chapter 5. Routing
- Chapter 6. Building APIs ← especially this one
- Part 1.Intro