动态创建的HttpRequest中的角度观察响应

时间:2018-12-28 13:50:28

标签: angular typescript httprequest httpclient response

尝试将{observe: 'response'}附加在正确的位置

 testRequest() {
    // let req = new HttpRequest(this.api.method, this.requestUrl)
    let req = new HttpRequest(this.api.method, this.requestUrl, {}, {
      observe: 'response' // <------ Type Error
    });

    if (this.api.method === METHOD.POST || this.api.method === METHOD.PUT) {
      req = req.clone({body: this.request.body});
    }
    req = req.clone({observe: 'response'}); // <---- No Go
    this.http.request(req).subscribe(result => {
      this.response = result;
    }, error => {
      this.response = error;
    });
  }

任何人都可以分享一个例子吗?

0 个答案:

没有答案
相关问题