Node Express Lesson 4

Middleware, REST Methods, and Postman

You will finish watching the video from the last few weeks. This week, you watch from 6:10:46 of the video to the end. The initial focus is on middleware. Then each of the HTTP methods involved in API development are covered: GET, POST, PUT, PATCH, and DELETE. As routes for each of these API methods are implemented, you will test them using Postman. You then refactor the code, to separate out the router and controller functions.

The front end calls the APIs in two ways, first as browser GET and POST requests coming from a standard HTML page, and second via JavaScript in the browser that issues GET, POST, PUT, and DELETE requests. You can find the front end in the methods-public directory. Study the two HTML files in this directory. They show you how to call the back end from the front end, using either ordinary HTML or JavaScript. When ordinary HTML is used, only GET and POST requests are supported, because those are the only operations a browser can natively do; and the POST request sends form-encoded data. When JavaScript is used, all HTTP operations are supported, and JSON is used to send and receive data. Parsing of the body of the request, for form-encoded and JSON data, is explained in the video.

This site needs some love. Come contribute; we're open to contributors! Come lend a hand!