Full-Stack Web Development with Vue.js and Node

(singke) #1
Building the Real Application Chapter 5

mode: 'history',
routes: [
{
path: '/',
name: 'Home',
component: Home,
},
{
path: '/contact',
name: 'Contact',
component: Contact,
},
{
path: '/movies/add',
name: 'AddMovie',
component: AddMovie,
},
],
});

Now, we can all route without adding the # in the URL as follows:


http://localhost:8080/
http://localhost:8080/contact
http://localhost:8080/movies/add

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
Free download pdf