Skip to content

Commit

Permalink
trimming the code
Browse files Browse the repository at this point in the history
  • Loading branch information
buchatsky committed Jan 20, 2022
1 parent 640dd6d commit d862d01
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/ng-http-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class AngularHttpProvider implements IAjaxProvider<Response> {
const d = Object.assign({}, AngularHttpProvider.defaultOptions);
o = mergeAjaxOptions(d, o);

// WithCredentials
// credentials (present in fetch RequestInit, absent in AjaxOptions)
//let ngWithCredentials = o.credentials && o.credentials == "include" ? true : false;

const promise = this.http.request(<string>o.method, <string>o.url, {
Expand All @@ -33,10 +33,14 @@ export class AngularHttpProvider implements IAjaxProvider<Response> {
//withCredentials: ngWithCredentials
}).toPromise()
.then((ngResponse: HttpResponse<Blob>) => {
let respHeaders = new Headers();
// vanilla
/*let respHeaders = new Headers();
ngResponse.headers.keys().forEach((key: string) => {
respHeaders.append(key, <string>ngResponse.headers.get(key));
respHeaders.append(key, ngResponse.headers.get(key)!);
});
*/
// hackish
let respHeaders = ngResponse.headers.keys().reduce(((ret, key: string) => (ret[key] = ngResponse.headers.get(key)) && ret), <any>{});

let response = new Response(ngResponse.body, {
headers: respHeaders,
Expand Down

0 comments on commit d862d01

Please sign in to comment.