Friday, 22 January 2016

I'm posting data to my Node app but can't seem to retrieve the data from within Node itself.

I'm attempting to post data to my Node app$.ajax({ dataType: "json", method: "POST", url: "/users/new", data: { first_name: "Conor", last_name: "McGregor", id: 3 }, success: function (data) { console.log("Success: ", data); }, error: function (error) { console.log("Error: ", error); } }); . . . but am unsure of how to access the post data from within the app itself.userRouter.route("/new") .post(function (req, res) { console.log(req); //console.log(req.body); } There doesn't seem to be any good documentation as to how to accomplish something so simple for Node--at least that's what I'm finding after over an hour of searching. Any idea how to accomplish this?

Submitted January 22, 2016 at 05:51PM by ExNihil

No comments:

Post a Comment