From 6204e1d53db8fe81cc26ab36f1673fc6b365c119 Mon Sep 17 00:00:00 2001 From: itzMiney Date: Mon, 30 Dec 2024 04:45:13 +0100 Subject: [PATCH] Updated article service methods and admin dashboard --- src/app/services/article.service.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/app/services/article.service.ts b/src/app/services/article.service.ts index e01456d..f2e5fdd 100644 --- a/src/app/services/article.service.ts +++ b/src/app/services/article.service.ts @@ -25,19 +25,18 @@ export class ArticleService { constructor(private http: HttpClient) {} getAllArticles(): Observable { - const timeStampedUrl = "/api/articles?timestamp=" + new Date().getTime(); - return this.http.get(timeStampedUrl); + return this.http.get(`${this.apiUrl}?timestamp=${new Date().getTime()}`); } getArticleBySlug(slug: string): Observable
{ - return this.http.get(this.apiUrl).pipe( - map((articles) => articles.find((article) => article.slug === slug)) + return this.http.get
(`${this.apiUrl}/${slug}`).pipe( + map(article => article) ); } getArticleById(id: number): Observable
{ - return this.http.get(this.apiUrl).pipe( - map((articles) => articles.find((article) => article.id === id)) + return this.http.get
(`${this.apiUrl}/${id}`).pipe( + map(article => article) ); }