我正在尝试从服务调用中获取响应,该服务返回pdf的blob。我已经拨打了电话,但不确定如何订阅。这是我的代码
service.ts
openDoc(val) {
const token = this._storeService.getStoredData().access_token;
const headers = new HttpHeaders()
.set('Authorization', `Bearer ${token}`)
.set('Content-Type', 'application/pdf')
.set('observe', 'response')
.set('responseType', 'blob');
const options = { headers: headers };
const url = val;
return this._http.get<any>(url, options);
}
component.ts
//我试图获得斑点
openDocWindow(url: string) {
this._candidateService.openDoc(url).subscribe(res => {
console.log("response"+ res);
this.currentDocumentUrl = res;
this.showDocumentWindow = true;
});
}