I am successfully getting json data from a web API. It is logging correctly to server console, but when I pas it to client it is coming as blank []
.
What am I doing wrong?
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 '[]'
});
});
I need to pass balance.data[0].total
from server to controller. What am I doing wrong and How can I make this work?
via chuckieDub
No comments:
Post a Comment