0

I'm beginner and I'm trying to get one user data in MongoDB with retrofit.I already got create and get all users(CR).In my case, db.users.findOne({}).It's work in commend line and not work in coding of server side.Although I checked request.params.id, it's also right.Please help me. Commendline check

Serverside code

Postman check

  • @Neil Lunn ..Well, I got answer but it's still have problem. Could you help me? how can I fix it?` Error: Uncaught error: Argument passed in must be a single String of 12 byte s or a string of 24 hex characters at new ObjectID` – Kyaw Min Htwe May 16 '18 at 02:52
  • It's not an `ObjectID` is why, so my bad for presuming it was. `db.users` just looks wrong for a NodeJS API. Which driver are you using? Only something like mongoskin or similar have that syntax. The core driver would be `db.collection('users').findOne({ _id: +req.params.id })`. You probably just need the `+` though since it's numeric. If that at least works, then let me know and I'll switch the duplicate. If you still don't get a result, then please post "text" of your code and NOT screenshots, and I'll reopen to look at what your problem possibly could be. – Neil Lunn May 16 '18 at 03:09
  • @Neil Lunn Thanks Sir. wow..You're right. You saved my time. Thanks you very much again. It's work by adding `+`. I must learn more and more, I'm newbie in it. Here is what I'm doing. []https://github.com/behindtheshadow/a-server-side-code-for-retrofit-push-demo – Kyaw Min Htwe May 16 '18 at 04:13

0 Answers0