Updated article service methods and admin dashboard
This commit is contained in:
1 parent
e6c0a2400a
commit
6204e1d53d
1 file changed
+5
-6
@@ -25,19 +25,18 @@ export class ArticleService {
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
getAllArticles(): Observable<Article[]> {
|
||||
const timeStampedUrl = "/api/articles?timestamp=" + new Date().getTime();
|
||||
return this.http.get<Article[]>(timeStampedUrl);
|
||||
return this.http.get<Article[]>(`${this.apiUrl}?timestamp=${new Date().getTime()}`);
|
||||
}
|
||||
|
||||
getArticleBySlug(slug: string): Observable<Article |undefined> {
|
||||
return this.http.get<Article[]>(this.apiUrl).pipe(
|
||||
map((articles) => articles.find((article) => article.slug === slug))
|
||||
return this.http.get<Article>(`${this.apiUrl}/${slug}`).pipe(
|
||||
map(article => article)
|
||||
);
|
||||
}
|
||||
|
||||
getArticleById(id: number): Observable<Article |undefined> {
|
||||
return this.http.get<Article[]>(this.apiUrl).pipe(
|
||||
map((articles) => articles.find((article) => article.id === id))
|
||||
return this.http.get<Article>(`${this.apiUrl}/${id}`).pipe(
|
||||
map(article => article)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user