Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda