2016-02-12 108 views
0

目前我正在建立一个后端系统,从我的网络中的几个设备获取信息。在某些设备上,我使用“PUT”方法来更改值。TypeError HTTP呼叫流星

Meteor.http.put('http://192.168.178.98:8080/test' , {content: "1"}, {headers:{"content-type":"text/plain"}}); 

这是工作,但两分钟后我的服务器与此错误崩溃:

W20160212-09:50:46.430(1)? (STDERR) TypeError: object is not a function W20160212-09:50:46.430(1)? (STDERR) at packages/http/httpcall_server.js:74:1 W20160212-09:50:46.430(1)? (STDERR) at packages/underscore/underscore.js:750:1 W20160212-09:50:46.431(1)? (STDERR) at Request._callback (packages/http/httpcall_server.js:116:1) W20160212-09:50:46.431(1)? (STDERR) at Request.self.callback (/home/pd/.meteor/packages/http/.1.1.1.158nqs7++os+web.browser+web.cordova/npm/node_modules/request/request.js:344:22) W20160212-09:50:46.431(1)? (STDERR) at Request.emit (events.js:98:17) W20160212-09:50:46.431(1)? (STDERR) at Request. home/pd/.meteor/packages/http/.1.1.1.158nqs7++os+web.browser+web.cordova/npm/node_modules/request/request.js:1239:14) W20160212-09:50:46.431(1)? (STDERR) at Request.emit (events.js:117:20) W20160212-09:50:46.431(1)? (STDERR) at IncomingMessage. /home/pd/.meteor/packages/http/.1.1.1.158nqs7++os+web.browser+web.cordova/npm/node_modules/request/request.js:1187:12) W20160212-09:50:46.431(1)? (STDERR) at IncomingMessage.emit (events.js:117:20) W20160212-09:50:46.432(1)? (STDERR) at _stream_readable.js:944:16 => Exited with code: 8 => Meteor server restarted

这是由客户端称为服务器端方法。

我该如何解决这个问题?是否可以禁用回调?

任何帮助表示赞赏。

回答

0

你应该把标题放在params对象中! 阅读documentation

Meteor.http.put('http://192.168.178.98:8080/test', { 
    content: "1", 
    headers: { 
     "content-type": "text/plain" 
    } 
}, function(err, res) { 

}); 
+0

谢谢。它的工作没有任何问题:) – pdunker