Angular2 - .post()/ .put()不起作用

时间:2016-07-18 20:59:31

标签: angular

尝试进行angular2 .post()/。put()调用,但后端没有任何内容。没有错误,没有。似乎电话只是死了

import 'rxjs/add/operator/map';
import {Http, Headers, RequestOptions} from '@angular/http';

let body = JSON.stringify(this.user);
    let headers = new Headers({
        'Content-Type': 'application/json'
    });
    let options = new RequestOptions({ headers: headers });

    return new Promise( ( resolve ) => {
        this.http.post( this.LOGIN_URL, body, options )
            .map( ( res ) => res.json() )
            .subscribe(
                ( data ) => resolve(data),
                ( error ) => resolve(error)
            );
        });

当我更改为.get()/ .delete()时,我收到节点后端的调用,所以,工作正常:

this.http.get( this.LOGIN_URL ) 
this.http.delete( this.LOGIN_URL ) 

我的.post()/ .put()调用有什么问题?

0 个答案:

没有答案