I'm retrieving data through a get request and displaying them in a Table, if I refresh the page I'll always have the request happening the way I want it to, but if change the route and come back to the table page, it will get data cached from the first service, because of this, if I delete an item, it disappears from the table. If I change routes, the item will comeback, since the cached data still has the item I deleted. Thanks in advance!
This is the request, it's executed on NgOnInit()
getSolicitacoes():Observable<any[]> {
return this.http.get<any[]>(URL_API + '/solicitacao', httpOptionsUno);
}
This how I get and delete the data displayed in the table
getSolicitacoes() {
this.solicitacaoService.getSolicitacoes().subscribe( data => {
this.solicitacoes = data;
this.dtTrigger.next();
}, error => {
console.log(error);
})
}
apagarSolicitacao(id, index) {
this.solicitacaoService.deleteSolicitacao(id).subscribe(data => {
this.toast.success('Solicitação deletada com sucesso!');
this.solicitacoes.splice(index,1);
}, error => {
console.log(error);
this.toast.error('Não foi possível deletar a solicitação!');
},
() => this.rerender()
)
}
I've already tried adding meta tags to my html with cache-control, pragma and expires headers. I'm sorry for my english, tried to find a solution on my language but it's been a struggle.