0
0
Angularframework~10 mins

HttpClientModule setup in Angular - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import HttpClientModule in the Angular module.

Angular
import { [1] } from '@angular/common/http';
Drag options to blanks, or click blank then click option'
AHttpClient
BHttpModule
CHttpHeaders
DHttpClientModule
Attempts:
3 left
💡 Hint
Common Mistakes
Importing HttpClient instead of HttpClientModule
Using deprecated HttpModule
Importing from wrong package
2fill in blank
medium

Complete the code to add HttpClientModule to the imports array in the Angular module.

Angular
@NgModule({
  imports: [[1]],
})
export class AppModule {}
Drag options to blanks, or click blank then click option'
AHttpClientModule
BBrowserModule
CFormsModule
DCommonModule
Attempts:
3 left
💡 Hint
Common Mistakes
Adding HttpClient instead of HttpClientModule
Forgetting to add it to imports
Adding unrelated modules
3fill in blank
hard

Fix the error in the code by completing the import statement correctly.

Angular
import { HttpClient } from '[1]';
Drag options to blanks, or click blank then click option'
A@angular/common/http
B@angular/forms
C@angular/core
D@angular/http
Attempts:
3 left
💡 Hint
Common Mistakes
Importing from @angular/http which is deprecated
Importing from @angular/core or @angular/forms
4fill in blank
hard

Fill both blanks to complete the Angular module setup for HTTP.

Angular
@NgModule({
  imports: [BrowserModule, [1]],
  providers: [[2]]
})
export class AppModule {}
Drag options to blanks, or click blank then click option'
AHttpClientModule
BHttpClient
CFormsModule
DCommonModule
Attempts:
3 left
💡 Hint
Common Mistakes
Adding HttpClient to imports instead of providers
Adding unrelated modules or services
Forgetting to add HttpClientModule
5fill in blank
hard

Fill all three blanks to complete the Angular service using HttpClient.

Angular
import { Injectable } from '@angular/core';
import { [1] } from '@angular/common/http';

@Injectable({ providedIn: 'root' })
export class DataService {
  constructor(private [2]: HttpClient) {}

  getData() {
    return this.[3].get('/api/data');
  }
}
Drag options to blanks, or click blank then click option'
AHttpClient
Bhttp
ChttpClient
DHttpHeaders
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong import names
Using inconsistent variable names
Calling get() on wrong variable