2016-02-12 106 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