【发布时间】:2014-05-10 22:33:30
【问题描述】:
我正在尝试创建一个路由以从 JSON-RPC API 返回 JSON 数据。
我的代码:
router.get('/balance', function(req, res, client) {
res.json({
client.getBalance('*', 1, function(err, balance) {
if(err)
console.log(err);
else
console.log('Balance: ', balance);
});
});
});
它使用 npm 包 node-litecoin。我需要它并像这样创建了一个客户端变量:
var client = new litecoin.Client({
host: 'localhost',
port: 9332,
user: 'myaccount',
password: 'mypass'
});
client.getBalance('*', 1, function(err, balance) { ^ SyntaxError: Unexpected token .
为什么会出现这个错误?
【问题讨论】:
-
如何让路由
'/balance'输出client.getBalance()函数?
标签: javascript json node.js express