Skip to content

Commit

Permalink
Put API method
Browse files Browse the repository at this point in the history
  • Loading branch information
codingXpert committed Jul 23, 2022
1 parent 018338d commit 6e6c376
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions dbConnFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ async function dbConnect(){
}

module.exports = dbConnect;


14 changes: 12 additions & 2 deletions postApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 6e6c376

Please sign in to comment.