Post returns { __v: 0, _id: 584640962825c6ace606fe9d }

Hello,

I am trying to submit a form, and it returns { __v: 0, _id: 584640962825c6ace606fe9d } - and I have no idea whats wrong with my Gift.create(newGift. Let me show you my route file:

and this is my form:

So I have 2 issues.

  1. When I submit this form, Im getting: { “_id” : ObjectId(“58464d78b474d7b17b3de44b”), “__v” : 0 }
  2. If I change res.redirect(’/users/’ + req.params.id + ‘/gifts’) to res.redirect(’/users/’ + req.params._id + ‘/gifts’) and the Gift.create to reflect that, req.params._id is undefined.

:cry:

Looks like you are missing body parser and your post route is missing :id

Hello again :slight_smile: So in my app.js I have bodyParser and am using it.

app.use(bodyParser.urlencoded({extended: true}));

Also, I am using app.use('/users/:id/gifts', giftsRoute); - I have screen hero if you want to jump on?

I’m currently on mobile. I’ll take a look at your code later on my pc.

EDIT:

In your gift.js file, shouldn’t Gift.create have all parameters to be documents?

Gift.create(req.body.id, newGift, function (err, newlyCreated) {...

I couldn’t find what is req.body.id.