节点j是否支持跨域请求?

时间:2015-05-11 09:12:40

标签: node.js

我已经从节点js中的http方法调用了跨域URL。但是我收到的错误是"找不到getaddressinfo"。

我的代码:

var http = require('http');

var options = {
    host: 'www.google.com',
    path: '/index.html'
};

var req = http.get(options, function(res) {
 console.log('STATUS: ' + res.statusCode);
 console.log('HEADERS: ' + JSON.stringify(res.headers));

 // Buffer the body entirely for processing as a whole.
 var bodyChunks = [];
 res.on('data', function(chunk) {
   // You can process streamed parts here...
   bodyChunks.push(chunk);
 }).on('end', function() {
   var body = Buffer.concat(bodyChunks);
   console.log('BODY: ' + body);
   // ...and/or process the entire body here.
 })
});

req.on('error', function(e) {
 console.log('ERROR: ' + e.message);
});

任何人都可以帮助解决这个问题。

感谢。

0 个答案:

没有答案
相关问题