integrated handling for new thumbnail field from api response

This commit is contained in:
itzMiney committed 2026-04-28 13:10:21 +02:00
1 parent 36501d3096
commit 3def7a9936
12 files changed
+182 -46

No files matched your search

+10 -3
View File
@@ -8,6 +8,7 @@ interface Article {
title: string;
slug: string;
content: string;
thumb_url: string | null;
createdAt: string;
updatedAt: string;
views: number;
@@ -46,10 +47,16 @@ export class ArticleService {
);
}
postArticle(token: string, title: string, content: string ): Observable<any[]> {
postArticle(
token: string,
title: string,
content: string ,
thumb_url?: string | null
): Observable<any> {
return this.http.post<any[]>(this.apiUrl, {
title,
content
content,
thumb_url: thumb_url?.trim() || null,
},{
headers: {
'Authorization': `Bearer ${token}`
@@ -70,7 +77,7 @@ export class ArticleService {
editArticle(
id: number,
token: string | null,
updates: { title?: string; content?: string }
updates: { title?: string; content?: string, thumb_url?: string | null }
): Observable<any> {
const headers = new HttpHeaders().set('Authorization', `Bearer ${token}`);
return this.http.put<any>(`${this.apiUrl}/${id}`, updates, { headers });