Skip to content

Commit d5cd8ed

Browse files
committed
implement search method
1 parent 4c2866d commit d5cd8ed

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/app/flight-search/flight-search.component.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,25 @@ export class FlightSearchComponent {
2121
ngOnInit(): void {}
2222

2323
search(): void {
24-
// Method body will be implemented later
24+
const url = 'http://www.angular.at/api/flight';
25+
26+
const headers = {
27+
Accept: 'application/json',
28+
};
29+
30+
const params = {
31+
from: this.from,
32+
to: this.to,
33+
};
34+
35+
this.http.get<Flight[]>(url, { headers, params }).subscribe({
36+
next: (flights) => {
37+
this.flights = flights;
38+
},
39+
error: (errResp) => {
40+
console.error('Error loading flights', errResp);
41+
},
42+
});
2543
}
2644

2745
select(f: Flight): void {

0 commit comments

Comments
 (0)