Node Js Notes
Node Js Notes
js Notes
Nodejs api // this is build in packages which is install with nodes js and are
helpful for making work easier
Fs //this is used to create a file and also write a masge inside it and send it to
user
Fs.appenfile(“path_of_file”, “masage”, “callBack function”)
Install express
Import it in file
Create a variable and store express functionality in it
Give a port address to run sever on it
Use different methods to get and post data to server
// do working hare
App.get(‘/address’, function(request,response){ response.send(‘Aslam o
Alaikum)}) // when we type this address to our browser then we will
receive this massage , Basically get method is used to get data form
server
….
db.on('error',(err)=>{
console.log('MongoDb connection error:',err);
});
db.on('disconnected',()=>{
console.log('MongoDb Disconnected');
});
Express Router
There are lots of endpoint in a project and include all endpoint in single
server file make code readability is much difficult.
Express js provide feature of express.router which help to manage
routes between different endpoint files