21.) How do you set global headers for every HTTP request?
A) Using an HttpInterceptor
B) Setting headers in every HttpClient request
C) Using a config file
D) Using HttpHeaders.setGlobal()
22.) What is the main advantage of using Angular HTTPClient?
A) It removes the need for servers
B) It makes API calls faster
C) It supports observables and RxJS operators
D) It works without a backend
23.) How do you transform an API response before using it?
A) Using map() in RxJS
B) Using filter()
C) Using delay()
D) Using concatMap()
24.) What is the correct way to handle timeouts in Angular HTTP requests?
A) delay()
B) setTimeout()
C) catchError()
D) timeout() operator in RxJS
25.) Which operator is used to handle multiple API calls sequentially in Angular?
A) switchMap
B) mergeMap
C) concatMap
D) forkJoin
26.) Which Angular lifecycle hook is best for making API calls?
A) ngOnInit()
B) ngOnDestroy()
C) ngAfterViewInit()
D) ngDoCheck()
27.) How do you test Angular HTTP services?
A) Using HttpTestClient
B) Using HttpClientTestingModule
C) Using APIUnitTestModule
D) Using HttpMockService
28.) What is take(1) used for in Angular HTTP requests?
A) To add a delay before execution
B) To increase API performance
C) To retry the request if it fails
D) To take the first API response and unsubscribe automatically
Related