I am trying to implement file download in angular 5.For this I trying to retrieve a file located in my localhost using get request and trying to convert it into blob object.
let headers = new HttpHeaders();
headers = headers.set('Accept', 'application/pdf');
return this.http.get('http://localhost/angular5/lesson2.pdf', {
headers: headers,
responseType: 'blob'
}).subscribe((res) => {
var blob = new Blob([res], { type: 'application/pdf' });
console.log(blob);
this.fileName(res);
saveAs(blob, "testData.pdf");
});
in the above code I trying to access a file located in my localhost in get request,but it shows following error

How can I solve this issue?