【发布时间】:2019-01-22 09:40:50
【问题描述】:
我直接与设备通信。
当我输入浏览器IP时
http://192.168.12.1/myconfig?pass=1&name=mywifi&passIS=87654321
在浏览器中显示此消息:config is ok。
现在,在我的项目中,我创建了一个输入值的表单。在 service.ts 中,我创建了 POST 方法,如下所示:
public createConfiguration(NewConfiguration: Configuration) {
let headers = new Headers();
headers.append('Content-Type', 'application/Json');
let body = NewConfiguration.generateUrlencodedParameters();
let url = ('http://192.168.12.1/myconfig?')
this.httpclient.post(url, body, {
}).subscribe(d=>{
console.log('response create newconfiguration', d)
})
}
这个函数显示错误:
JS: ERROR {
JS: "headers": {
JS: "normalizedNames": {},
JS: "lazyUpdate": null,
JS: "headers": {}
JS: },
JS: "status": 0,
JS: "statusText": "Unknown Error",
JS: "url": null,
JS: "ok": false,
JS: "name": "HttpErrorResponse",
JS: "message": "Http failure response for (unknown url): 0 Unknown Error",
JS: "error": {
JS: "originalStack": "Error: java.io.EOFException\n at new c (file:///data/data/org.nativescript.myapp/files/app/vendor.js:1:1217697)\n at file:///data/data/org.nativescript.myapp/files/app/vendor.js:1:1083743\n at Object.onComplete (file:///data/data/org.nativescript.myapp/files/app/vendor.js:1:1084864)",
JS: "zoneAwareStack": "Error: java.io.EOFException\n at new c (file:///data/data/org.nativescript.myapp/files/app/vendor.js:1:1217697)\n at file:///data/data/org.nativescript.myapp/files/app/vendor.js:1:1083743\n at Object.onComplete (file:///data/data/org.nativescript.myapp/files/app/vendor.js:1:1084864)"
JS: }
JS: }
消息config is ok 在正文中。
请问您知道如何解决此错误吗?
【问题讨论】:
-
控制台正文并确保您的查询参数必须以正确的形式发送。
-
我发送正确的查询参数
标签: angular typescript http httpclient nativescript