Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

166
Visualizações
I want to use @ngneat/cashew with interceptor for cache HTTP request does it possible?

Please read the instruction of @ngneat/cashew before answering this question from here @ngneat/cashew

The Idea is simple instead of doing this in service level like this,

this.httpClient.get<Posts>(`http://localhost:3000/posts/${id}`,{context:withCache()});

I want to make a global interceptor. Here is my code snippet,

# Config of Interceptor
{
      provide: HTTP_INTERCEPTORS, useClass: CacheInterceptor, multi: true
 }

# Here is CacheInterceptor 

intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
    const modifiedRequest = request.clone(
      {context: withCache()}
    );
    return next.handle(modifiedRequest);
  }

I want to do this because adding { context : withCache() } in every service's method is repetitive, otherwise in a existing project it it too much time killer. That's why I want achive this via making a custom Interceptor. Does it possible to achieve ?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda