1
我使用MeanJs使用MEAN堆棧。問題是,我有一個任務需要從服務器端(Expressjs)調用GET請求到另一個服務器(使用不同的域名)。使用MEAN堆棧從服務器控制器獲取請求
在客戶端的代碼(AngularJs)稱:
$scope.getWorkflow = function() {
$http.get('/ezee', $scope.credentials).success(function(response) {
console.log(response.message);
}).error(function(response) {
console.log('error');
});
};
以及相應的服務器控制器的功能是:
exports.list = function(req, res) {
req.get('http://ezslave.io', function(q, r){
res.json({message: r.message}); // just to test
});
};
顯然,下面的代碼無法正常工作。我不確定如何從list
函數發出GET請求。我是否應該爲此使用ExpressJs或純粹的NodeJs?以及如何獲得正確的庫加載?
我剛開始用Node.js的打算,所以我不能自信地回答,但我敢肯定這是你要找的內容:HTTP: //nodejs.org/api/http.html#http_http_get_options_callback –