admin管理员组

文章数量:1123399

I have encountered a peculiar scenario where a the same exact api request using fetch vs Angular's HttpClient has a difference. Particularly, the Traceparent and Request-id are automatically added by fetch but Angular doesn't.

Given the fact, I also have used the HttpClient now with the following provider added to the ApplicationConfig:

import { provideHttpClient, withFetch } from '@angular/common/http';
...
provideHttpClient(withFetch())

I was assuming that since HttpClient will use fetch under the hood because of this declaration of provider that is using withFetch, it will carry over the two headers just like a raw fetch would do. But apparently it does not.

So this seems to be a three part question:

  1. What are these headers?
  2. How are these attached by fetch?
  3. Should I file an issue on Angular's GitHub regarding HttpCLient's withFetch not exactly doing what fetch would do?

本文标签: