Tuesday, June 18, 2019

Bring back the kind of Observable of an Array that you may carry into an Angular 7 component template and use with the async pipe from the HttpClient in the '@angular/common/http' npm package.

HttpHeaders is in '@angular/common/http' too:

public GetFoo():Observable<Array<Foo>> {
   let token:string = this.activeDirectoryContract.GetAccessToken();
   let header = new HttpHeaders().set('Authorization', 'Bearer ' + token);
   return this.httpClient.get<Array<Foo>>(environment.apiUrl + "foo",
         { headers: header });
}

No comments:

Post a Comment