Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 934 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Argument passed in must be a string of 24 hex characters - I think it is

#11
const ID = (req.body.id).trim();

Worked for me, actually `(req.body.id)` adds an extra space to the ID variable.

After I used `.trim()` method it worked.

Reply

#12
I got the same error. Later I found that I have included a whitespace while sending the values to the server.

<input type="checkbox" name="checkbox" value="<%= item._id %>" onchange="this.form.submit()" />


In the value attribute I had typed as <code>value="<%= item._id %> " </code>. A whitespace after the ID. It caused to that error. After I removed it(<code>value="<%= item._id %>" </code>), the problem solved.

The below code worked for me.

item.findOne({'_id':id} , (err)=>{

if(err){
console.log(err);
}
else{
console.log("Item Found");
}
});

Reply

#13
I have tried all answers. But it doesn't work for me. Maybe if you are getting params with express. It's worked for me. Try this;

var MongoClient = require('mongodb').MongoClient;
const {ObjectId} = require('mongodb');

app.get('/:id', (req, res) => {

var reqId = req.params.id
var query = reqId.toString()


MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("AllDB");
dbo.collection("Events").findOne({_id: ObjectId(query)}, function(err, result) {
if (err) throw err;
res.send(result)
db.close();
});
});

})

**Update :**

Hey, I give same error again, and I notice new solution. If your code like this:

app.get('/', (req, res) => {
res.send('TEST')
})


app.get('/:id', (req, res) => {

var reqId = req.params.id
var query = reqId.toString()

})

Could you try change your get request route. Maybe such as app.get('/findid/:id)

It worked for me. I was searching again and i found this way.

Thanks, Regards.
Reply

#14
Actually the Id you are fetching have whitespaces in it so adding trim() to your id will work

const id = (req.params.id).trim();
const result = await deleteOne({_id:new mongodb.ObjectId(id)});


while using this code keep in mind that your function should be async and mongodb should have been imported.
Reply

#15
Sometimes clearing your local storage could be the solution to this error. From 'inspect' just go to Application>local storage and select the URL. Then press the 'clear all' sign. It worked for me.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through