@ -17,9 +17,11 @@ export type RawArticle = {
|
||||
description?: string
|
||||
cover: string
|
||||
brand_name: string
|
||||
brand_id?: number
|
||||
year: number
|
||||
image_count: number
|
||||
published_at: number
|
||||
created_at?: number
|
||||
source_url?: string
|
||||
collection_type?: string
|
||||
season?: string
|
||||
@ -113,10 +115,11 @@ export function loadArticles(): Promise<Loaded> {
|
||||
return _loaded
|
||||
}
|
||||
|
||||
export async function fetchArticleById(id: number | string): Promise<RawArticle | null> {
|
||||
if (!API_BASE) return null
|
||||
export async function fetchArticleById(id: number | string, apiBase: string = API_BASE): Promise<RawArticle | null> {
|
||||
const base = apiBase.replace(/\/$/, "")
|
||||
if (!base) return null
|
||||
try {
|
||||
const res = await fetch(`${API_BASE}/api/public/articles/${id}`)
|
||||
const res = await fetch(`${base}/api/public/articles/${id}`)
|
||||
if (!res.ok) return null
|
||||
const json: any = await res.json()
|
||||
return json?.data ?? null
|
||||
|
||||
Reference in New Issue
Block a user