Can you help me figure out why I am unable to send the input from my form and download a file at the same time?
this.fg = this.fb.group({
rptReqCode:[''],
rptCode:[''],
parFldVal:[''],
genType:[]
})
}
downloadFile( filename: string = null): void{
const token = 'my JWT';
const headers = new HttpHeaders().set('authorization','Bearer '+token);
this.http.get(this.appsetting.baseURL + 'File/Download' ,{headers, responseType: 'blob' as 'json'}).subscribe(
(response: any) =>{
let dataType = response.type;
let binaryData = [];
binaryData.push(response);
let downloadLink = document.createElement('a');
downloadLink.href = window.URL.createObjectURL(new Blob(binaryData, {type: dataType}));
if (filename)
downloadLink.setAttribute('download', filename);
document.body.appendChild(downloadLink);
downloadLink.click();
}
)}