24 lines
546 B
JavaScript
24 lines
546 B
JavaScript
export async function getPublicContent(lang) {
|
|
const id = lang === 'fa' ? 1 : 2
|
|
const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL
|
|
|
|
if (!baseUrl) {
|
|
console.error('NEXT_PUBLIC_API_BASE_URL is not set')
|
|
return {}
|
|
}
|
|
|
|
try {
|
|
const res = await fetch(`${baseUrl}/api/public/content/index/${id}`)
|
|
|
|
if (!res.ok) {
|
|
console.error(`Failed to fetch public content: ${res.status}`)
|
|
return {}
|
|
}
|
|
|
|
return res.json()
|
|
} catch (error) {
|
|
console.error('Failed to fetch public content', error)
|
|
return {}
|
|
}
|
|
}
|