指定由节点中的hubot创build的GET请求的callback函数

我们当地的Hubot(“Sparky”)运行大量的插件脚本,并且一般运行良好。 我正在写一个插件脚本,对Yahoo Pipes进行GET调用,并期待JSONP的结果。 但是,我不确定如何使用_callback参数。 码:

 module.exports = (robot) -> robot.hear /\bkeyword\b/i, (msg) -> robot.http("http://pipes.yahoo.com/pipes/pipe.run") .query({ _id: "legit-pipe-id-is-here", _render: "json", _callback: "?" }) .get() (err, res, body) -> if body? data = JSON.parse(body) 

这得到的错误是:

 undefined:1 _({"count":10,"value":{"title":"correct title","description":"Pipes Output","lin ^ SyntaxError: Unexpected token _ at Object.parse (native) at e:\node\sparky\scripts\plugin-name.coffee:26:11, <js>:11:23 at IncomingMessage.<anonymous> (e:\node\sparky\node_modules\hubot\node_modules\scoped-http-client\lib\index.js:70:20) at IncomingMessage.EventEmitter.emit (events.js:117:20) at _stream_readable.js:920:16 at process._tickCallback (node.js:415:13) 

我已经validation了,在使用jQuery的ajax函数时,pipe道工作正常,但是在这种情况下,jQuery设置了自己的callback函数。

我只是意识到,我不需要使用JSONP,所以我不需要一个_callback参数。 当你不在浏览器中时,常规的JSON工作正常,杜:

 module.exports = (robot) -> robot.hear /\bkeyword\b/i, (msg) -> robot.http("http://pipes.yahoo.com/pipes/pipe.run") .query({ _id: "legit-pipe-id-is-here", _render: "json" }) .get() (err, res, body) -> if body? data = JSON.parse(body)