Files
uldp.edu.vn/api/aboutApi.ts
2026-02-06 12:09:33 +07:00

36 lines
1006 B
TypeScript

/**
* About API Functions
* Fetch about us data from external API
*/
const getApiUrl = (): string => {
return process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001";
};
import { AboutData } from "../app/about/types";
export const aboutApi = {
// Get about us data
getAbout: async (): Promise<AboutData | null> => {
try {
const apiUrl = getApiUrl();
const response = await fetch(`${apiUrl}/api/about`, {
// Không cache - luôn fetch dữ liệu mới nhất
cache: 'no-store',
headers: {
'Content-Type': 'application/json',
}
});
if (!response.ok) {
console.error(`HTTP error! status: ${response.status}`);
return null;
}
return await response.json();
} catch (error) {
console.error("Error fetching about data:", error);
return null;
}
},
};