feat(about): Implement about API integration and migrate from static JSON

This commit is contained in:
2026-02-06 02:01:42 +07:00
parent a85182ff20
commit dc68fe17ab
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;
}
},
};