how to store a token in request headers and make another API call using that token in header?

106 Views Asked by At

In angular 7 with Reactive programming, how to store a token in session storage and make another API call using that token in header?

service.ts

public getResponse(data: object) {
    return this.http.post(`${this.baseURL}`, data, { observe: 'response' })
        .pipe(concatMap(res2 => this.http.get(`${this.baseURL1}`)))
}

now where to include this line for storing token from 1st api call? because 2nd API call is based on token.

localStorage.setItem("token",res.headers.get('X-Auth-Token'));
0

There are 0 best solutions below