January 2018
Intermediate to advanced
348 pages
8h 17m
English
We do have the token, but for us to be able to invoke the IMS Issues resource method of /issues, we now need to pass the Authorization request header. To do so, we will update our getAll() method within IssuesService to pass the token as part of the request:
@Injectable()export class IssuesService { constructor(private http: HttpClient) { } public getAll(): Observable<Array<Issue>> { return this.http.get<Array<Issue>>( 'http://localhost:8082/ims-issues/resources/issues', { headers: new HttpHeaders().set( 'Authorization', `Bearer ${localStorage.getItem('token')}` ) }); }//Other methods omitted}
The second argument to the http.get call are the options that we can pass to set the headers on this request. We ...
Read now
Unlock full access