feat(core): update
This commit is contained in:
23
lib/content.js
Normal file
23
lib/content.js
Normal file
@@ -0,0 +1,23 @@
|
||||
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 {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user