From 6e6c376115eb0a3039225ac2fa1d55417cf7bbe9 Mon Sep 17 00:00:00 2001 From: Vivek Date: Sat, 23 Jul 2022 13:49:28 +0530 Subject: [PATCH] Put API method --- dbConnFile.js | 1 + postApi.js | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dbConnFile.js b/dbConnFile.js index 5a92a4b..7219e1b 100644 --- a/dbConnFile.js +++ b/dbConnFile.js @@ -12,4 +12,5 @@ async function dbConnect(){ } module.exports = dbConnect; + diff --git a/postApi.js b/postApi.js index 5aaf589..7fdc394 100644 --- a/postApi.js +++ b/postApi.js @@ -18,8 +18,18 @@ app.get('/' , async (req , res) => { //post api app.post('/' , async (req , res) => { let data = await dbConnect(); - data = await data.insert(req.body); - res.send(data); + let result = await data.insert(req.body); + res.send(result); }); +//put api +app.put('/:xyz' , async(req ,res)=>{ +let data = await dbConnect(); +let result = data.updateOne( + {name:req.params.xyz} , + {$set:req.body} +) +res.send({result:"update"}) +}) + app.listen(8000); \ No newline at end of file