You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letexpress=require("express");letbodyParser=require("body-parser");letserver=express();//body parser for parsing request bodyserver.use(bodyParser.json());server.use(bodyParser.urlencoded({extended: true}));//temperary store for `item` in memoryvaritemStore=[];//GET all itemsserver.get('/item',function(req,res){res.json(itemStore);});//GET the item with specified idserver.get('/item/:id',function(req,res){res.json(itemStore[req.params.id]);});//POST new itemserver.post('/item',function(req,res){itemStore.push(req.body);res.json(req.body);});//PUT edited item in-place of item with specified idserver.put('/item/:id',function(req,res){itemStore[req.params.id]=req.bodyres.json(req.body);});//DELETE item with specified idserver.delete('/item/:id',function(req,res){itemStore.splice(req.params.id,1)res.json(req.body);});//START SERVERserver.listen(3000,function(){console.log("Server running");});