Help Needed: I have a service file with two methods, each having its own API. I want to call the getData method within the deleteData method. Can anyone guide me on how to achieve this?
.service.file
getData(): Promise<PagedResult<Sites>> {
const url = `${environment.DATA_API_URL}/sites/GetSites`;
console.log(url);
return this.httpClient.get<PagedResult<Sites>>(url).toPromise().then((sites: PagedResult<Sites>) => {
alert();
console.log("sites: ",sites);
});
}
deleteData(siteId: String): Observable<{}>{
const url = `${environment.HELLO_API}/Data?siteId=`+ siteId;
return this.httpClient.post(url, this.getSites)
.pipe(
catchError(this.handleError('deletSites'))
);
}
.ts file
async ngOnInit(){
this.sites = await this.dataService.getData();
console.log(this.data)
}