A
A
Andrew_Kanaev2016-08-17 23:03:29
Node.js
Andrew_Kanaev, 2016-08-17 23:03:29

How is the data received from the form?

Hello! I came across a series of articles: Easy Node Authentication: Setup and Local . I can not understand how the data is received from the form?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Leo Developer, 2016-08-18
@crazy_leo

If the data goes by the GET method, then the data is received from the address bar, if POST, then requestan event is hung on the object Like datathis

http.createServer(function (req, res) {
 if (req.method == "POST" && req.url == "example") {
 req.on("data", function (chunk) {
 // и здесь все парсится
})
}
}).listen(3000)
and express does it all for you, and stores the data transmitted by the POST method in a property, bodyi.e. req.body
And here https://scotch.io/tutorials/easy-node-authenticat... everything is done through passport,
read this code https:/ /github.com/scotch-io/easy-node-authenticat...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question