Skip to content

Commit e2c2772

Browse files
committed
fix: Troubleshooting G2 SSR request failure process
1 parent 9f8a659 commit e2c2772

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

g2-ssr/app.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ http.createServer((req, res) => {
1414
if (req.method === 'GET') {
1515
toGet(req, res);
1616
} else if (req.method === 'POST') {
17-
console.log('POST123')
1817
toPost(req, res);
1918
}
2019
}).listen(port, () => {
@@ -52,15 +51,10 @@ function getOptions(type, axis, data) {
5251
// 创建 Chart 和配置
5352
async function GenerateCharts(obj) {
5453
const options = getOptions(obj.type, JSON.parse(obj.axis), JSON.parse(obj.data));
55-
console.log('options')
5654
const chart = await createChart(options);
57-
console.log('createChart')
58-
5955
// 导出
6056
chart.exportToFile(obj.path || 'chart');
6157
// -> chart.png
62-
console.log('exportToFile')
63-
6458
chart.toBuffer();
6559
}
6660

@@ -77,17 +71,10 @@ function toGet(req, res) {
7771
function toPost(req, res) {
7872
const bodyChunks = []
7973
req.on('data', function (chunk) {
80-
console.log('data')
8174
bodyChunks.push(chunk)
82-
console.log('tobuffer')
83-
}).on('end', function () {
75+
}).on('end', async () => {
8476
const completeBodyBuffer = Buffer.concat(bodyChunks);
85-
console.log('toBuffer', completeBodyBuffer.toString('utf8'))
86-
});
87-
res.end('complete', async () => {
88-
console.log('complete')
89-
// const completeBodyBuffer = Buffer.concat(bodyChunks);
90-
// console.log('toBuffer', completeBodyBuffer.toString('utf8'))
91-
// await GenerateCharts(JSON.parse(completeBodyBuffer.toString('utf8')))
77+
await GenerateCharts(JSON.parse(completeBodyBuffer.toString('utf8')))
9278
});
79+
res.end('complete');
9380
}

0 commit comments

Comments
 (0)