Issue
i am using ionic/angular for my app. In the starting screen (not splashscreen) I get a .json file from my server with
this.apiService.getEvents().subscribe res => {
console.log(res);
});
getEvents(): Observable<any> {
let headers = new HttpHeaders({
'Content-Type': 'application/json; charset=utf-8'
});
return this.httpClient.get("https:www.someURL.com/somejson.json", { headers: headers });
}
but the Observable thingy is caching the whole response. Our file "somejson.json" is manually changed and the ionic app should reload its content at every appstart.
So, how do you NOT cache HTTP GET ? thanks in advance ;)
Solution
Please use destroy before subscribing to avoid caching.
private readonly _destroy$: Subject<void> = new Subject<void>();
this.apiService.getEvents().pipe(takeUntil(this._destroy$)).subscribe res => {
console.log(res);
});
Answered By - Ritu Riya
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.