为什么我的JSON客户端不起作用?

时间:2012-05-07 21:09:32

标签: node.js restify

我正在关注这里的例子

http://mcavage.github.com/node-restify/#JsonClient

如下

    var client = restify.createJsonClient({
        url: 'http://api.stackoverflow.com'
    });
    client.get('/1.1/users/19068', function(err, req, res, obj) {
      assert.ifError(err);
      console.log('%j', obj);
    });

我收到以下错误消息

 SyntaxError: Unexpected token
  at Object.parse (native)
  at /.../node_modules/restify/lib/clients/json_client.js:54:20
  at IncomingMessage.<anonymous> (/.../node_modules/restify/lib/clients/string_client.js:149:16)
  at IncomingMessage.g (events.js:156:14)
  at IncomingMessage.emit (events.js:88:20)
  at HTTPParser.onMessageComplete (http.js:137:23)
  at Socket.ondata (http.js:1147:24)
  at TCP.onread (net.js:354:27)

0 个答案:

没有答案