-1
Hello I would like to know how I can receive the data of my form in HTML in Node js, I have the login form and I want to receive and check if this user is valid, but I want to check in my file that check this in my file connection.js that will be done in Node, and if it is valid redirect it to index, I’m already a few days in this, I tried with:
req.body.username
But it doesn’t work, so I would like to know how I can send the data of this form to my file js to handle this information and return to the client, I want to do this using Ajax, I know it is not the best option but I think it is easier for me.
how is your HTML form? used method
POST
? Voce uses theexpress
on your Node and if so, Voce has set upexpress.urlencoded()
? You have yet to show more of your code, so we can help your problem. Try to edit your question.– Cmte Cardeal
Yes, I got it with req.body.username, I configured it right, and I used post method in route and HTML, but I can’t use it in connection.js file, I want to use this file just to check if the user exists, I don’t want to have to create a route for it.
– Naja210
and what appears in
req.body.username
. If you are using AJAX, that means Voce receives a JSON. configured theexpress.json()
?– Cmte Cardeal
I didn’t use Ajax, I need to use it I think, maybe it’s better, and what returns from req.body.username is the name of the user that is filled in the input.
– Naja210