We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
In request Construction the ondata is being to empty function
this.ondata = noop this.onend = noop
In server.js
parser[HTTPParser.kOnBody] = onbody function onbody (body, start, end) { req.ondata(body, start, end) }
So wondering if I am missing something here? How to do I receive POST data?
The text was updated successfully, but these errors were encountered:
Hi, I am pretty late but I will add it anyway. Here is a snippet for reading the body of a request.
const _body = req => new Promise(resolve => { const parts = []; req.ondata = (buffer, start, length) => { const part = buffer.slice(start, length + start).toString(); parts.push(part); }; req.onend = () => resolve(parts.join('')); });
Then you can use it in your server like that:
const http = require('turbo-http'); const server = http.createServer().listen(3000); server.on('request', async (req, res) => { const body = await _body(req); res.end(); });
Sorry, something went wrong.
@lucagez You saved my hours. @mafintosh Maybe we should add this snippet to documentation?
No branches or pull requests
In request Construction the ondata is being to empty function
In server.js
So wondering if I am missing something here? How to do I receive POST data?
The text was updated successfully, but these errors were encountered: