我将我的angular2应用程序升级到RC5,现在Http.delete操作失败(在它执行之前)成功之前。
这里是package.json:
"@angular/common": "2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.5",
"@angular/core": "2.0.0-rc.5",
"@angular/http": "2.0.0-rc.5",
"@angular/forms": "0.3.0",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
"@angular/router": "3.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.5",
以下是我如何使用它:
deleteUser(id){
let headers = new Headers({ 'Content-Type': 'application/json'});
let options = new RequestOptions({ headers: headers });
return this.http.delete(this._usersUrl + '/' + id, options)
.map(res => {
return <User>res.json()
})
.catch(this.handleError)
}
调试时我可以看到,直到http.delete 和执行删除操作时才会崩溃(DELETE不会发送到服务器)。我检查了docs for Http api以防我错过了一些论点,但我认为它们没问题。
仔细检查,没有执行任何删除操作,但其他HTTP操作正常。有任何线索吗?
我得到的错误如下:
platform-browser.umd.min.js:6 ORIGINAL EXCEPTION: TypeError: Cannot read property 'toString' of nullBrowserDomAdapter.logError @ platform-browser.umd.min.js:6ExceptionHandler.call @ core.umd.min.js:7next @ core.umd.min.js:10generatorOrNext.object.schedulerFn @ core.umd.min.js:10t.__tryOrUnsub @ Rx.min.js?cb=e6b3f62:11t.next @ Rx.min.js?cb=e6b3f62:11t._next @ Rx.min.js?cb=e6b3f62:11t.next @ Rx.min.js?cb=e6b3f62:11t._finalNext @ Rx.min.js?cb=e6b3f62:11t._next @ Rx.min.js?cb=e6b3f62:11t.next @ Rx.min.js?cb=e6b3f62:11EventEmitter.emit @ core.umd.min.js:10onError @ core.umd.min.js:10onHandleError @ core.umd.min.js:10e.handleError @ zone.min.js?cb=e6b3f62:1e.runGuarded @ zone.min.js?cb=e6b3f62:1NgZoneImpl.runInnerGuarded @ core.umd.min.js:10NgZone.runGuarded @ core.umd.min.js:10outsideHandler @ platform-browser.umd.min.js:7e.invokeTask @ zone.min.js?cb=e6b3f62:1e.runTask @ zone.min.js?cb=e6b3f62:1invoke @ zone.min.js?cb=e6b3f62:1
platform-browser.umd.min.js:6 ORIGINAL STACKTRACE:BrowserDomAdapter.logError @ platform-browser.umd.min.js:6ExceptionHandler.call @ core.umd.min.js:7next @ core.umd.min.js:10generatorOrNext.object.schedulerFn @ core.umd.min.js:10t.__tryOrUnsub @ Rx.min.js?cb=e6b3f62:11t.next @ Rx.min.js?cb=e6b3f62:11t._next @ Rx.min.js?cb=e6b3f62:11t.next @ Rx.min.js?cb=e6b3f62:11t._finalNext @ Rx.min.js?cb=e6b3f62:11t._next @ Rx.min.js?cb=e6b3f62:11t.next @ Rx.min.js?cb=e6b3f62:11EventEmitter.emit @ core.umd.min.js:10onError @ core.umd.min.js:10onHandleError @ core.umd.min.js:10e.handleError @ zone.min.js?cb=e6b3f62:1e.runGuarded @ zone.min.js?cb=e6b3f62:1NgZoneImpl.runInnerGuarded @ core.umd.min.js:10NgZone.runGuarded @ core.umd.min.js:10outsideHandler @ platform-browser.umd.min.js:7e.invokeTask @ zone.min.js?cb=e6b3f62:1e.runTask @ zone.min.js?cb=e6b3f62:1invoke @ zone.min.js?cb=e6b3f62:1
platform-browser.umd.min.js:6 TypeError: Cannot read property 'toString' of null
at Request.Body.text (http.umd.min.js:6)
at Request.getBody (http.umd.min.js:7)
at eval [as _subscribe] (http.umd.min.js:6)
at e.subscribe (Rx.min.js?cb=e6b3f62:11)
at e._subscribe (Rx.min.js?cb=e6b3f62:11)
at e.call (Rx.min.js?cb=e6b3f62:7)
答案 0 :(得分:-2)
随着Angular 2.0发布,请尝试将代码升级到稳定版本。