05 - Server Update
In this module, we'll add header files in our server.
Overview
We added some routes to app.js
earlier but didn't cover what was really happening there. In this module, we'll add to the app.js
file, giving it the ability to use middleware. We'll also try testing out the additional routes we added earlier, as well as use the test client to see how the client and server sides work together.
Referencing the Middleware
We exported the middleware, so now we need to use it when we spin up our server. Follow the steps: 1. Go into app.js
. 2. Add the following line of code under the bodyParser
variable:
Analysis
Here we activate our headers in the
app.js
. Keep in mind that this in order, so the file will be read sequentially, which means that the headers must come before the routes are declared.
Test Client
Let's test this in our client now with the following steps:
Your server should still be running, so we just need to start the client. Switch to the client terminal window and start it.
Go to your client and try clicking on the button that says Hello Client. You should see the result print to the console. Please note this is the only button that currently works.
Further Study
Look at this picture of the client-server relationship:
Explain the entire process, from the client creating of the request to receiving the response back from the server.
Last updated