Communicating with servers
We now have a movie listing page, we have an add movie page, so the next thing we have to do is save the data into the MongoDB when we submit the form.
Adding express to our application
Now that we have all the components in place, it's time to add the server layer to our application.
Let's start by adding the express package with the following:
npm install express --save
The next part is to create the necessary endpoints and models so that we can add the movies to the database.
To do that, we first need to install the required packages:
body-parser
: To parse the incoming requestscors
: To handle cross-origin requests between frontend and backendmorgan
: HTTP request loggermongoose
: Object modeling for MongoDB
Let's install all of these packages by running the following command in the Terminal:
$ npm install morgan body-parser cors mongoose --save
Adding a server file
Now, we need to set up the server for our application. Let's add a file called server.js
in the root of the...