Skip to content

Commit 9b1d421

Browse files
committed
fix: Troubleshooting G2 SSR request failure process
1 parent 4928b1a commit 9b1d421

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

g2-ssr/app.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,15 @@ function toGet(req, res) {
7474

7575
//获取POST请求内容、cookie
7676
function toPost(req, res) {
77-
req.on('data', async function (chunk) {
78-
console.log('data', chunk)
79-
await GenerateCharts(JSON.parse(chunk))
80-
console.log('toBuffer')
81-
res.end('complete');
77+
const bodyChunks = []
78+
req.on('data', function (chunk) {
79+
console.log('data')
80+
bodyChunks.push(chunk)
81+
console.log('tobuffer')
82+
});
83+
res.end('complete', async () => {
84+
const completeBodyBuffer = Buffer.concat(bodyChunks);
85+
console.log('toBuffer', completeBodyBuffer.toString('utf8'))
86+
await GenerateCharts(JSON.parse(completeBodyBuffer.toString('utf8')))
8287
});
8388
}

0 commit comments

Comments
 (0)