Hello,
I need to call a JAX-RS service which returns an excel file and i need to
download locally this file. I have googled to see how to do it in Angular
and found lots of samples for Angular 2 which don't work in Angular 4 and
HttpClient.
For example I found this:
public downloadFile2(bundleIds: Array<String>, langIds: Array<String>):
Observable<Blob> {
let options = new RequestOptions({ responseType: ResponseContentType.Blob
});
return this.http.get(this.url, options).map(res => res.blob());
}
It doesn't compile and flags the following error message at the last line
(options):
[ts]
Argument of type 'RequestOptions' is not assignable to parameter of type '{
headers?: HttpHeaders; observe?: "body"; params?: HttpParams;
reportProgress?: boolean; respons...'.
Types of property 'headers' are incompatible.
Type 'Headers' is not assignable to type 'HttpHeaders'.
Property 'headers' is missing in type 'Headers'.
What seems to happen is that HttpClient requires HttpHeaders parameters
while this example is using Headers. Could someone please provide me with a
working example of downloading an Excel file or, at least, how to solve the
error above ?
Many thanks in advance,
Nicolas
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.