0

I have my own HTTP Service which provides GET, POST, PUT and DELETE methods and enables me to send the JWT from my Firebase user in the HTTP request header.

Now I'm able to get my user object from a redux store, and I can retrieve the JWT via the getIdToken() method on this user object. Unfortunately this method provides me with a Promise<string>.

Is there any way, I can build my Http-Options Object with this JWT-Header, before actually sending the request via Angular's HttpClient?

My Code:

async delete<T = any>(appendix: string): Observable<T> {
  const options: any = await this.httpOptions();
  return this.http.delete<T>(this.url + appendix, options);
}
    
private async httpOptions(): Promise<{ headers: { uid: string } }> {
  const user: User = this.authQuery.getValue();
  const token: string = await user.getIdToken().catch();
  return {
    headers: {uid: token},
  };
}
Christopher Peisert
  • 21,862
  • 3
  • 86
  • 117
Andreas Rainer
  • 314
  • 4
  • 16

0 Answers0