我想通过URL指定获取的网站内容到变量。
请求sample.js
fun <T> iterativeKleisli(n: Int, f: (T) -> T) : (T) -> T = { x ->
var result = x
for (i in 1..n)
result = f(result)
result
}
var request = require('request');
var html = '';
request('https://www.google.com', function(error, response, body) {
html = body;
});
// Below, proceed with processing using saved contents
console.log(html);
我该如何解决?