This commit is contained in:
Tomas Dvorak
2025-11-21 08:44:44 +01:00
parent c941313fd5
commit f5b6f83974
108 changed files with 8642 additions and 5871 deletions
+3 -2
View File
@@ -199,7 +199,7 @@ export async function deleteArticle(id: number | string) {
export async function getArticleBySlug(slug: string) {
try {
const res = await api.get<Article>(`/articles/slug/${encodeURIComponent(slug)}`);
return res.data;
return normalizeArticle(res.data);
} catch (e) {
// Fallback: attempt list query through normalized helper and return first match
const list = await getArticles({ slug });
@@ -239,7 +239,8 @@ export async function uploadFile(file: File) {
export async function trackArticleView(id: number | string) {
try {
await api.post(`/articles/${id}/track-view`);
// Send an explicit empty JSON body to satisfy backend Content-Type validation
await api.post(`/articles/${id}/track-view`, {});
} catch (e) {
console.debug('Failed to track article view:', e);
}