My code for PUT method is not working . Can somebody explain app.put('/update/:id', async (req,res) =>{ // console.log(req.params.id) const data = await dbConnect(); const result = await data.updateOne( {_id: req.params.id}, {$set: req.body} ) res.send(result); }) o/p at postman { "acknowledged": true, "modifiedCount": 0, "upsertedId": null, "upsertedCount": 0, "matchedCount": 0 }
@@devanshurawat826 app.put('/:_id', async (req, resp) => { let data = await dbConnect(); data = await data.updateOne( { _id: new ObjectId(req.params._id) }, { $set: req.body } ); resp.send(data); }); and import the objectId like this const { ObjectId } = require('mongodb');
Great method of teaching
very well explained
Completely doubt solving video
SIR YOUR EFFORTS ARE PRICE LESS, BTW SIR ONE QUESTION WHAT DO YOU THINK IS MORE EASY FRONT END OR BACKEND? LOVE FROM PAKISTAN ❤❤❤❤
bhaiya abhi tak jitna aapne bata dia hai agar use krke we can build somethng chahe chota hi to please give link. koi chota sa project
thank you sir
Api Method or Api Endpoints me kya difference hai?
Complex api's with multiple collection kab tak aayegi sir ?
Soon
great
The data is not updated in this method, u just ran the code , and the status is sent in res.send() by default
Bro u made mistake to understand this
app.put('/update/:id', async (req, res) => {
let db = await dbConnection();
db = await db.updateOne(
{ _id: ObjectId(req.params) },
{
$set: req.body,
}
);
res.send(db);
});
😊
hii
can you help me in api creation
app.put("/update/:id",async(req,res)=>{
const fullDB = await dbConnection();
const data = await fullDB.updateOne({_id:new ObjectId(req.params.id)},{$set:req.body});
res.send(data);
})
lecture 37 completed
can any one help me i am stucked for 5 days in the api sections
if anyone is good with api in node js please contact me
First Comment I want heart
My code for PUT method is not working . Can somebody explain
app.put('/update/:id', async (req,res) =>{
// console.log(req.params.id)
const data = await dbConnect();
const result = await data.updateOne(
{_id: req.params.id},
{$set: req.body}
)
res.send(result);
})
o/p at postman
{
"acknowledged": true,
"modifiedCount": 0,
"upsertedId": null,
"upsertedCount": 0,
"matchedCount": 0
}
app.put("/update/:id",async(req,res)=>{
const fullDB = await dbConnection();
const data = await fullDB.updateOne({_id:new ObjectId(req.params.id)},{$set:req.body});
res.send(data);
})
getting same problem on console, while postman still "sending request..."
@@devanshurawat826 app.put('/:_id', async (req, resp) => {
let data = await dbConnect();
data = await data.updateOne(
{ _id: new ObjectId(req.params._id) },
{ $set: req.body }
);
resp.send(data);
});
and import the objectId like this
const { ObjectId } = require('mongodb');
great