在Meteor中进行api调用

时间:2015-08-23 16:20:55

标签: javascript http meteor

如何在Meteor中获得与以下卷曲代码相同的结果?

curl https://pwint.ly/api/v1.0/Page \
   -u test_48c1a7647c6a419ebc9109f6150a7925:9b758ef621d44be2b51a3e913a58ca97 \
   -H "Content-Type: application/json" \
   -d {'urls':[{'original':'https://farm9.staticflickr.com/8593/15663081584_0e51fa0841_o_d.jpg',}],'yourid':'1234','returnurl':'http://www.example.com/returnurl'}

我试图像这样使用Meteor http包:

  apiCall : function () {
        var result = HTTP.post("https://pwint.ly/api/v1.0/Page", {

         data: {'urls':[{'original':'https://farm9.staticflickr.com/8593/15663081584_0e51fa0841_o_d.jpg'}],'yourid':'1234','returnurl':'http://192.168.1.141:3000'}

        });

        console.log(result.content)
        console.log(result.data) //<< JSON form (if api reports application/json as the content-type h
  }

但是我收到了这个错误:

Exited with code: 8
=> Your application is crashing. Waiting for file change.
W20150823-12:13:19.648(-4)? (STDERR)     at Object.HTTP.post (packages/http/httpcall_common.js:56:1)
W20150823-12:13:19.648(-4)? (STDERR)     at Object.call (packages/meteor/helpers.js:119:1)
W20150823-12:13:19.648(-4)? (STDERR)     at [object Object].Meteor.methods.apiCall (app\art.js:48:24)
W20150823-12:13:19.648(-4)? (STDERR)     at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1617:1)
W20150823-12:13:19.649(-4)? (STDERR)     at packages/ddp/livedata_server.js:1530:1
W20150823-12:13:19.649(-4)? (STDERR)     at [object Object]._.extend.apply (packages/ddp/livedata_server.js:1529:1)
W20150823-12:13:19.649(-4)? (STDERR)     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
W20150823-12:13:19.650(-4)? (STDERR)     at [object Object]._.extend.call (packages/ddp/livedata_server.js:1472:1)
W20150823-12:13:19.650(-4)? (STDERR)     at app\art.js:68:8
W20150823-12:13:19.650(-4)? (STDERR)     at C:\Users\Raj\art\.meteor\local\build\programs\server\boot.js:222:10
W20150823-12:13:19.650(-4)? (STDERR)     at app\art.js:244:3
W20150823-12:13:19.651(-4)? (STDERR)     at Array.forEach (native)
W20150823-12:13:19.651(-4)? (STDERR)     at Function._.each._.forEach (C:\Users\Raj\AppData\Local\.meteor\packages\meteor-tool\1.1.4\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11)
W20150823-12:13:19.651(-4)? (STDERR)     at C:\Users\Raj\art\.meteor\local\build\programs\server\boot.js:117:5
W20150823-12:13:19.651(-4)? (STDERR)     - - - - -
W20150823-12:13:19.651(-4)? (STDERR)     at makeErrorByStatus (packages/http/httpcall_common.js:12:1)
W20150823-12:13:19.652(-4)? (STDERR)     at Request._callback (packages/http/httpcall_server.js:109:1)
W20150823-12:13:19.652(-4)? (STDERR)     at Request.self.callback (C:\Users\Raj\AppData\Local\.meteor\packages\http\1.1.0\npm\node_modules\request\request.js:344:22)
W20150823-12:13:19.652(-4)? (STDERR)     at Request.emit (events.js:98:17)
W20150823-12:13:19.652(-4)? (STDERR)     at Request.<anonymous> (C:\Users\Raj\AppData\Local\.meteor\packages\http\1.1.0\npm\node_modules\request\request.js:1239:14)
W20150823-12:13:19.652(-4)? (STDERR)     at Request.emit (events.js:117:20)
W20150823-12:13:19.653(-4)? (STDERR)     at IncomingMessage.<anonymous> (C:\Users\Raj\AppData\Local\.meteor\packages\http\1.1.0\npm\node_modules\request\request.js:1187:12)
W20150823-12:13:19.653(-4)? (STDERR)     at IncomingMessage.emit (events.js:117:20)
W20150823-12:13:19.653(-4)? (STDERR)     at _stream_readable.js:944:16
W20150823-12:13:19.654(-4)? (STDERR)     at process._tickDomainCallback (node.js:486:13)

我该怎么做才能解决这个问题?

0 个答案:

没有答案