mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 02:32:57 +00:00
dev day #99
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user