Module 11: HTTP Flashcards

1
Q

HTTP Import

A

import { HttpClientModule, HttpClient } from ‘@angular/common/http’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

HTTP Configure

A

imports: [HttpClientModule],
constructor( private http: HttpClient) { }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

HTTP Use

A

this.http.get(url).subscribe((res) => {
this.students = res;
this.sArray = this.students.student;
});

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the role of the HttpClient service in Angular?

A

The HttpClient service is used to make HTTP requests from an Angular application to interact with backend APIs, enabling data retrieval, submission, and communication with external servers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What lifecycle hook would you typically use to initiate an HTTP request when a component loads, and why?

A

The ngOnInit() lifecycle hook is typically used to initiate an HTTP request when a component loads because it is called after the component’s initialization, ensuring that all required data bindings are set up before the request is made.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly