Get and post method in Node js
// get user
app.get ('/',(req,res)=>{
const users =[
{id: 1 , name :"Amit "}
{id: 1 , name :"Rohan "}
];
res.json(users)
})
// create users
app.post('/user',(req,res)=>{
const {name, email} = req.body ;
res.status(201).json*({message: "created...."})
})
Post a Comment