-
Which one is best for production? app.post('/', (res, req) => {
let json;
res.onData((chunk, isLast) => {
if (isLast) {
json = JSON.parse(Buffer.from(chunk).toString());
}
});
res.end('some data')
}); or app.post('/', (res, req) => {
let json;
res.onData((chunk, isLast) => {
if(isLast){
json = JSON.parse(Buffer.from(chunk).toString());
res.cork(() => {
res.end('some data');
})
}
});
}); or app.post('/', (res, req) => {
let json;
res.onData((chunk, isLast) => {
if(isLast){
res.cork(() => {
json = JSON.parse(Buffer.from(chunk).toString());
res.end('some data');
})
}
});
}); or using JsonPost.js example |
Beta Was this translation helpful? Give feedback.
Answered by
ghost
Dec 9, 2020
Replies: 1 comment
-
The last alternative is better than the first, since you do use cork. But the second alternative is just as good for the same reason. This is covered in the user manual. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The last alternative is better than the first, since you do use cork. But the second alternative is just as good for the same reason. This is covered in the user manual.