Utilizing Angular10 and Typescript.
I want to avoid using 'window.location.reload()' when making multiple http.post requests in my application. Specifically, I am encountering an issue when trying to open a Dialog to edit the Parent's data.
dialog.afterClosed(){
window.location.reload()};
The function behind the 'send button' is as follows:
async onOkClick() {
var e = await this.groceryListCrudService.post(this.myData);
this.dialogRef.close('Ok');
}
This is the post function being called:
post(item: Partial<PortFolio>) {
return this.http.post<any>(this.url, item, this.httpOptions).subscribe({
next: (data) => {
this.post = data.id;
},
error: (error) => {
console.error('There was an error!', error);
},
});
}
Upon clicking the button twice, even after waiting for the data to be inserted into the database, I encounter the following error:
ERROR Error: Uncaught (in promise): TypeError: this.groceryListCrudService.post is not a function TypeError: this.groceryListCrudService.post is not a function
If more code is needed for further assistance, please let me know. Thank you!