简体   繁体   中英

Angular2 - RC5 Http.delete fails

Im upgrading my angular2 app to RC5 and now the Http.delete operation fails (before it gets executed) when it was succeeded before.

Here the 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",

Here is how Im using it:

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)
}

While debugging I can see that it gets until http.delete and while executing the delete operation something crashes (DELETE is not sent to server). I have checked the docs for Http api in case I'm missing some arguments but I think they are fine.

Checking more carefully, none of the delete operations get executed but others HTTP operations work fine. Any clue?

The error I get is the following:

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)

随着Angular 2.0的发布,请尝试将代码升级到稳定版本。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM