2017-01-04 45 views

回答

2
You can also use **http** module like this 

var http = require('http'); 
var options = { 
    host: 'localhost', 
    path: '/api/polls', 
    port: '80', 
    method: 'GET' 
}; 


var req = http.request(options, response); 
var str = '' 
    response.on('data', function (chunk) { 
    str += chunk; 
    }); 

    response.on('end', function() { 
    console.log(str); 
    res.render('profile', {'polls': str}); 
    }); 
req.end(); 
相關問題