Issue
I was trying to delete something from a project I'm working on, and I don't know how to do a put server request. The put request works properly, but the view is not updated after receiving the response.
markNotificationsAsReaded(not): Promise<any> {
return new Promise((resolve, reject) => {
this.http.put(`${environment.url}/notifications/view`, { "notification_id": not.id }).pipe(map(res => { return res })).subscribe(
(res: any) => {
resolve(res);
console.log('marcando como leido esto 2', res)
},
error => {
reject();
});
})
}
and this is the HTML code
<app-notification
*ngFor="let n of notificationService.notificationsList$ | async; let idx=index"
[idx]="idx"
[notification]="n"[]
(removeNotification)="getNotification(idx)"
>
<h4 ></h4>
</app-notification>
I'm new in this, sorry if it is a basic error
Solution
you need to update the variable 'notificationService.notificationsList$. By default http request is made only once.
So even with the asynchronous pipe you will have to call the function that creates this list again.
Answered By - Leo Chaves
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.