Created
October 8, 2019 12:04
-
-
Save IAfanasovMob/39f2f719463f8c034182378a52d6c198 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http'; | |
import { Observable } from 'rxjs'; | |
@Injectable() | |
export class GitHubApiVersionInterceptor implements HttpInterceptor { | |
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | |
if (req.url.startsWith('https://api.github.com/')) { | |
const clone = req.clone({ | |
setHeaders: { Accept: 'application/vnd.github.v3.star+json' } | |
}); | |
return next.handle(clone); | |
} | |
return next.handle(req); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment