Merge pull request 'feat(about): Implement about API integration and migrate from static JSON' (#23) from feat/huy-05022026-about-api-integration into main

Reviewed-on: UKSOURCE/hailearning.edu.vn#23
This commit is contained in:
2026-02-06 03:31:45 +00:00
5 changed files with 65 additions and 143 deletions

35
api/aboutApi.ts Normal file
View File

@@ -0,0 +1,35 @@
/**
* 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`, {
cache: 'no-store',
headers: {
'Cache-Control': 'no-cache',
'Pragma': 'no-cache'
}
});
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;
}
},
};