Cześć.
Mam problem w swoim Angular 9 z pobieraniem PDF. Otóż pobieranie odbywa się za pomocą HttClient.
kod - componentu :
generateQrLabel() {
this.creatorLabelService.generateQrLabel(this.mixtureUsageId, this.selectedSizeQrLabel).subscribe((data) => {
const downloadURL = window.URL.createObjectURL(data);
const link = document.createElement('a');
link.href = downloadURL;
link.download = "help.pdf";
link.click();
});
kod - service:
generateQrLabel(mixtureUsage: string, size = 1) {
const httpOptions = {
responseType: 'blob' as 'json',
headers: new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'
})
};
return this.http.get(`${environment.apiUrl}/generate/mini/label/` + mixtureUsage + '/' + size, httpOptions);
}
Moje nagłówki podczas wysyłania zapytania:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE2MDM4Njk4MzMsImV4cCI6MTYwMzg3ODQzMywicm9sZXMiOlsiUk9MRV9PV05FUiJdLCJ1c2VybmFtZSI6ImJvaGVtYS5taWNoYWxAZ21haWwuY29tIn0.JsoPlTxSImQvR0cHQa9OKp_Qvpu59tQBF6CRlGPIsH1aXLjiH77BAsyzjSjyEwJRIiGxx8govp5jr7nLrsIqf437DuQjDKXU38Y08wkocQW8oJR5T3xhF4fDyzQEn957sr6AydT6h3RHM9WrV09yG32XoSEpzW6i29pKJ6EnvrO4r-0ZfcW9mRLAn869QvqQla_wMVYN3EHOqYRNPeBHRUElBQcs44TKlQyaUZImETlDkMDbcsASOQNeCR5m3Tkct2o0BU2ySCMuwom9t13VzK-2M1BVCUClPS2FFG9hCNuuF3zNdtLXIzOLmiw35oXctyZh9Qji3jydI0VwMP5DL0uXg112jFfaPu2fMw6ZSTaP9Ir7t69l5kNGlOmBex9mxWsTculZfbQs6DbbC38buAphVmJtX-FqrGMfaro21-ntJ-KWhgmJGetlicGKjqTlwMCXj8coqD2b9GKLkKX9b6r4iwyiOvETVbWh9hTKuOKjmXw86oqeNgYAATm1nTzy4qWXegUzsRGW-yxnW2CfuF2Ro6VOY9QWMKJ9WBuSEc-jlebeUzfyv-JoLqKTluP9BboSQ23y6x3USj0wA59MUIXCMEO4Mp2wXbgUovSpBf-FVJhKa3xmV72G2ASRhO1GtsyG3xCtrXer48KWAy27yWSkqFILaZTjztUpeBzeh-k
Content-Type: application/x-www-form-urlencoded
Referer: http://localhost:4200/
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36
Problem jest, że ciągle dostaje nieznany błąd w consoli. Back-end działa dobrze bo był testowany i wszystko działa.
Z góry dziękuje za pomoc.