You will need 2 things:
-
HttpClientyou will need to perform depedency injection where you would call theprovideHttpClienthelper function in the app.config.ts. From there, you can use theHttpClientmethod. -
OnInitinterface (if you want to fetch data when a page is loaded)
example of an implementation:
export class AppComponent implements OnInit {
public http = inject(HttpClient)
ngOnInit() {
this.http.get(`some url`).subscribe(config => {
console.log('data', config)
})
}
}
Displaying the data
- need to use
@Input(for prop passing)