Last active
March 14, 2019 17:47
-
-
Save deksoke/c4bdf1f354bd4b91fabee79184ef936e to your computer and use it in GitHub Desktop.
Custom OData Query String with Http Interceptor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpErrorResponse, HttpResponse } from '@angular/common/http'; | |
@Injectable() | |
export class CustomInterceptor implements HttpInterceptor { | |
constructor() { } | |
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | |
if (request.params.has('$count')) { | |
let customParams = request.params.delete('$count'); | |
customParams = customParams.append('$inlinecount', 'allpages'); | |
request = request.clone({ params: customParams }); | |
} | |
return next.handle(request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment