My attempt to download a zip file to my local system using Angular's API response with the desired type as zip has been unsuccessful. Despite specifying the correct content-type and Accept headers, I keep encountering errors.
a.service.ts
download() {
const headers: HttpHeaders = new HttpHeaders({
"content-type": "application/json",
"Accept": "application/zip"
});
return this.http.get(url, {headers: headers, responseType: "arraybuffer"});
}
a.component.ts
getDownload() {
console.log("Hello world");
this.Service.download().subscribe((responseData: any) => {
console.log(responseData);
},(error: any) => {
});
Despite trying different response types such as "blob," "text," and "arraybuffer," I have yet to find a solution to the error that persists during the download process.