Friday, 3 July 2020

[total noob] Why am I not able to access this post request body from my html form?

here is my html form:


​Here is my JavaScript POST request:userRouter.post('/users/signup', (req, res) => {const {userName, password} = req.bodyUser.create({userName, password}).then(u => res.status(201).send(u)).catch(e => { throw new Error(e) })})If I send a POST request using Postman and send JSON data in the body, I can actually add stuff to my database and get my 201 status code. When I send a GET request using the above html (replacing post with get) I am able to get the values via req.query. However, I am unable to get form data into my userRouter.post method. Is there an easy way to do this?thanks in advance for the help

Submitted July 04, 2020 at 12:49AM by animalCollectiveSoul

No comments:

Post a Comment