I try to send an GET request from Angular to my Laravel backend.
Route::get('excel', function () {
return Excel::download(new PqrsExport, 'products.xlsx');
});
I subscribe to this method
get_excel(){
this.pqrService.getExcel().subscribe(
resp => console.log(resp),
err => console.log(err)
);
}
And get this
HttpErrorResponse {headers: HttpHeaders, status: 200, statusText: "OK", url: "http://localhost:8000/excel", ok: false, …}
headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ}
status: 200
statusText: "OK"
url: "http://localhost:8000/excel"
ok: false
name: "HttpErrorResponse"
message: "Http failure during parsing for http://localhost:8000/excel"
error: {error: SyntaxError: Unexpected token P in JSON at position 0 at JSON.parse (<anonymous>) at XMLHtt…, text: "PKVGSPG�D�X�[Content_Types].xml�…heets/_rels/sheet1.xml.relsPK��"}
__proto__: HttpResponseBase
return response()->json(Excel::download(new PqrsExport, 'products.xlsx'))
? – Alezco05