Skip to content

Commit a1237c8

Browse files
committed
interceptor added
1 parent bf41179 commit a1237c8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/main.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
import { bootstrapApplication } from '@angular/platform-browser';
2-
import { provideHttpClient } from '@angular/common/http';
2+
import { HttpHandlerFn, HttpRequest, provideHttpClient, withInterceptors } from '@angular/common/http';
33

44
import { AppComponent } from './app/app.component';
55

6+
function loggingInterceptor(req: HttpRequest<unknown>, next: HttpHandlerFn) {
7+
/*
8+
const newReq = req.clone({
9+
headers: req.headers.set('new-Header', 'headerValue')
10+
});
11+
*/
12+
13+
console.log('Interceptor: ', req);
14+
return next(req);
15+
}
16+
617
bootstrapApplication(AppComponent, {
7-
providers: [provideHttpClient()],
18+
providers: [provideHttpClient(withInterceptors([loggingInterceptor]))],
819
}).catch(err => console.error(err));

0 commit comments

Comments
 (0)