This file teaches you to create an Express Server.
- npm init -y --> To install NPM
- npm install express --> To install express dependencies
- Create index.js --> First point of contact
- Look for the file for how to do it?
- Run the app using node
- Mostly you will get 4** error bcoz there are no API Routes
- Go to index.js again and have a look at the configuration for routes section
Install nodemon for hot-reloading
npm i -D nodemon --> -D only for developers not in production Go to package.json --> change scripts -> "start":'echo .....' to "start":'node index.js' Go to package.json --> add to scripts -> "dev":'nodemon index'
- Create a folder called public
- add html files to a subfolder called pages
- Import path module into the index.js
- Create a path for accessing the file
res.sendFile(path.join(__dirname,'public','pages','index.html'));
- Create a route to send the array of objects
- When the route is hit the array will be returned
- Look in the data section of index.js