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) {}
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
getAllArticles(): Observable<Article[]> {
|
getAllArticles(): Observable<Article[]> {
|
||||||
const timeStampedUrl = "/api/articles?timestamp=" + new Date().getTime();
|
return this.http.get<Article[]>(`${this.apiUrl}?timestamp=${new Date().getTime()}`);
|
||||||
return this.http.get<Article[]>(timeStampedUrl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getArticleBySlug(slug: string): Observable<Article |undefined> {
|
getArticleBySlug(slug: string): Observable<Article |undefined> {
|
||||||
return this.http.get<Article[]>(this.apiUrl).pipe(
|
return this.http.get<Article>(`${this.apiUrl}/${slug}`).pipe(
|
||||||
map((articles) => articles.find((article) => article.slug === slug))
|
map(article => article)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getArticleById(id: number): Observable<Article |undefined> {
|
getArticleById(id: number): Observable<Article |undefined> {
|
||||||
return this.http.get<Article[]>(this.apiUrl).pipe(
|
return this.http.get<Article>(`${this.apiUrl}/${id}`).pipe(
|
||||||
map((articles) => articles.find((article) => article.id === id))
|
map(article => article)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user