Transcript from the "Create a Document on POST Request" Lesson
>> Scott Moss: And then if I wanted to create a note, so if I did a post request to ('/note', asynch(req, res). First thing is I'll do is I'll get the note that is trying to be created. So in Express, we will get that on the request object. So I'll say notesTobeCreated = req.body.
[00:00:28] So if you do an Ajax call to the server, whatever you place in the body will be added to this object req.body. That's how Express works. Other frameworks and languages are very similar. So I got the note to be created and then I'll just create it. So notes = await Note.create(noteTobeCreated) and that's it.
[00:00:52] And then I'll just say res.status, it's a post, so I'll be a good engineer and do a (201) for a post. And then I'll send back the note, and that's it. So I created a note from the object that was sent to the server, and then I send it back after I created it.