Angular constructor loads twice when httpClient functions are called from the same constructor.
export class ViewOrderDetailsComponent {
constructor(
private activatedRoute: ActivatedRoute,
private router: Router,
private httpClient:HttpClient) {
console.log("_______________constructor____________");
this.httpClient.get("https://jsonplaceholder.typicode.com/todos/1",{headers: null, params:null}).subscribe();
//constructor loads once if above line is commented.
}
}
Is it not suggested to make api call from constructor?