Fixed getAllArticles() method in Article Service by adding timestamp to API request (yes this took me hours to figure out)

This commit is contained in:
itzMiney committed 2024-12-30 04:03:01 +01:00
1 parent dae95810f2
commit e6c0a2400a
2 files changed
+4 -2

No files matched your search

+2 -1
View File
@@ -80,7 +80,8 @@ export const routes: Routes = [
}, },
{ {
path: 'blog/:slug', path: 'blog/:slug',
component: ArticlePageComponent }, component: ArticlePageComponent
},
{ {
path: '**', path: '**',
pathMatch: 'full', pathMatch: 'full',
+2 -1
View File
@@ -25,7 +25,8 @@ export class ArticleService {
constructor(private http: HttpClient) {} constructor(private http: HttpClient) {}
getAllArticles(): Observable<Article[]> { getAllArticles(): Observable<Article[]> {
return this.http.get<Article[]>(this.apiUrl); const timeStampedUrl = "/api/articles?timestamp=" + new Date().getTime();
return this.http.get<Article[]>(timeStampedUrl);
} }
getArticleBySlug(slug: string): Observable<Article |undefined> { getArticleBySlug(slug: string): Observable<Article |undefined> {