DEV Community

ID-GO
ID-GO

Posted on

Unable to await Delete Method.

await this.configurationService.deleteTrf(this.trfCode);
this.afterStatusChange();

deleteTrf(trfCode : string) {
let url =
${this.getTrfApiUrl()}${trfCode};
return this.http.delete(url).pipe(
map((apiResponse) => {
return this.apiResponseHandler.handleApiResponse(apiResponse);
}),
catchError(error =>{
this.loggerService.error(
Could not delete Trf Code ${trfCode} , error);
throw new Error(
Deletion of Trf ${trfCode} failed);
})
);
}

*Requirement *

  1. await this.configurationService.deleteTrf(this.trfCode);

Until the Above line is completed below line should wait (2)

  1. this.afterStatusChange();

Top comments (2)

Collapse
 
gaurangdhorda profile image
GaurangDhorda

Rather await you can subscribe () and inside subscribe add your code.
this.configurationService.deleteTrf(this.trfCode).subscribe ( e =>{
this.afterStatusChange();
} )

So this subscribe code block runs only after delete request completed. Kind of await for you. For further discussion you can connect with me by email grdtechlab@gmail.com thanks!

Collapse
 
idgo profile image
ID-GO

Thanks..