小编ssc*_*ler的帖子

如何在不将其转换为字符串或json的情况下访问Angular 2 http响应主体?

我想复制一个REST响应成团块,但我不能做一些,因为blob()arrayBuffer()尚未响应对象已经实施.Response Body是一个私有变量.

...
return this.http.get(url, {params: params, headers: headers})
     .map(res => {   
        // can't access _body because it is private
        // no method appears to exist to get to the _body without modification             
        new Blob([res._body], {type: res.headers.get('Content-Type')});
     })
     .catch(this.log);
...
Run Code Online (Sandbox Code Playgroud)

在实施这些方法之前,我是否可以使用解决方案?

rest blob httpresponse angular2-http angular

23
推荐指数
3
解决办法
3万
查看次数

标签 统计

angular ×1

angular2-http ×1

blob ×1

httpresponse ×1

rest ×1