I am calling a service which builds and returns an http call return =(this.http.get(API URL). I subscribe to the service as below and it tells me that the value is undefined, I should try passing in an Observable:
documentDownload(documentUrl) {
const queryParams = new HttpParams()
.set('Code', this.code);
return this.http.get((documentUrl), {params: queryParams}).subscribe(resp => this.DocDownload(resp));
}
below is the docDownload to actually open the pdf:
DocDownload(data) {
const blob = new Blob([data], { type: 'application/pdf' }); //octet-stream
const url = window.URL.createObjectURL(blob);
window.open(url);
}
I believe I am subscribing correctly and I've tested the service it returns a valid link so why is that it's running into this undefined error?