1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Does the httpResource have an HttpContext?

Discussão em 'Angular' iniciado por T. Jami, Agosto 7, 2025.

  1. T. Jami

    T. Jami Guest

    httpResource got released as an experimental feature in Angular 19.2. The httpResource uses the HttpClient under the hood. So I was hoping, I would be able to pass all the options I could pass to the HttpClient to the httpResource as well. However I cannot find anything about the option HttpContext in httpResource. I was wondering if there is a way to still use the context within the httpResource.

    I am maintaining an open source library (Github: ng-openapi) and I would like to implement the support for httpResource. However since I am providing the option to have multiple clients and provide an option to add scoped HttpInterceptors, I need to differentiate the fired http requests among the generated clients. For that I used the HttpContext option in HttpClient.

    One possible solution would be to add a custom headers. But that would mean my client identifier will also be sent to the server as well. I would like to avoid that (it just feels better). I technically could also remove the added header within the interceptor, but that makes it a bit more complex than necessary. This might be the last solution I would consider, but I really hope I could use the HttpContext.

    Appreciate your time and any possible ideas.

    PS: does it make sense to add a new tag to SO? (angular-httpresource)


    Continue reading...

Compartilhe esta Página