There is no body in http request
mawesome4ever opened this issue · 2 comments
mawesome4ever commented
I have the following code:
http.createServer(function (req, res)
print(req.body)
}
but it returns nil. After looping through req i see the follow:
As you may see, there's no body. Also, what's with the documentation not having any descriptions of anything or at least any examples? https://luvit.io/api/http.html
truemedian commented
luvit's builtin http
library is a port of the nodejs http
library, which is almost entirely callback oriented. To get the request body you need to use req:on('data', fn)
and req:on('end', fn)
to capture (and probably buffer) the request body.
As for the other question: the luvit documentation is not maintained whatsoever and most things just don't have documentation.
mawesome4ever commented
Oh that makes sense! Just looked at nodejs wiki page and it helped, thanks!