-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3 Created TokenInceport too add Headers too the request..
- Loading branch information
Peter Schneider
authored and
Peter Schneider
committed
Sep 11, 2020
1 parent
acbbaca
commit 6b4904c
Showing
4 changed files
with
44 additions
and
16 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { | ||
HttpRequest, | ||
HttpHandler, | ||
HttpEvent, | ||
HttpInterceptor | ||
} from '@angular/common/http'; | ||
import { Observable } from 'rxjs'; | ||
@Injectable() | ||
export class TokenInterceptor implements HttpInterceptor { | ||
|
||
constructor() {} | ||
|
||
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | ||
request = request.clone({ | ||
setHeaders: { | ||
'Ocp-Apim-Subscription-Key': '272101d76e92479c9762f658ecff0dc3' | ||
} | ||
}); | ||
return next.handle(request); | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient, HttpHeaders } from '@angular/common/http'; | ||
|
||
|
||
const headers = new HttpHeaders() | ||
.set('Ocp-Apim-Subscription-Key', '272101d76e92479c9762f658ecff0dc3'); | ||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
|
||
|
||
export class HttpService { | ||
constructor(private http: HttpClient) { } | ||
|
||
url = 'https://preview-demo-mm.azure-api.net/private/api/management/apis?'; | ||
|
||
getCharacters() { | ||
return this | ||
async getCharacters() { | ||
await this | ||
.http | ||
.get(`${this.url}`, { headers }); | ||
.get(this.url).subscribe(data => { | ||
return data; | ||
}); | ||
} | ||
} | ||
|