0
我从web API成功获取json数据。它正确地记录到服务器控制台,但是当我将它传递给客户端时,它将作为空白[]
。如何将此json数据从服务器传递到控制器? Nodejs/AngularJS
我在做什么错?
app.get('/balance', function(req, res) {
var poloniexExchange = new Cryptox(
"poloniex", {
key: 'IGVRQCXB',
secret: '93b5686d9ef'
});
//get all account balances
poloniexExchange.getBalance({
account: 'all'
}, function(err, balance) {
if (err)
console.log(err);
if (!err)
console.log(balance.data[0].total); //logging all json data
res.json(balance.data[0].total);
});
});
app.controller('websocketController', function($scope, $http) {
$http.get("/balance")
.then(function(response) {
console.log(response.data); //logging '[]'
});
});
我需要从服务器传递到balance.data[0].total
控制器。我做错了什么,我该如何做这项工作?