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},
  };
}
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.