通过http.get字符串添加体
我怎么可以添加从HTTP身体得到的字符串(VAR的getText)?
var GetText ;
require('https').get('/?num=1&min=1&max=10&col=1&base=10&format=plain&rnd=new', (res) => {
res.setEncoding('utf8');
res.on('data', function (body) {
console.log(body);
});
});
console.log(GetText);
回答如下:
你需要一个缓冲变量在内部res.on(“数据”)来添加然后设置的getString变量的res.on(“结束”)事件。这里是一个很好的文章,如果您想了解更多的问题。
https://nodejs/en/docs/guides/anatomy-of-an-http-transaction/
通过http.get字符串添加体
我怎么可以添加从HTTP身体得到的字符串(VAR的getText)?
var GetText ;
require('https').get('/?num=1&min=1&max=10&col=1&base=10&format=plain&rnd=new', (res) => {
res.setEncoding('utf8');
res.on('data', function (body) {
console.log(body);
});
});
console.log(GetText);
回答如下:
你需要一个缓冲变量在内部res.on(“数据”)来添加然后设置的getString变量的res.on(“结束”)事件。这里是一个很好的文章,如果您想了解更多的问题。
https://nodejs/en/docs/guides/anatomy-of-an-http-transaction/