no stotre cache

This commit is contained in:
Philip Cheung 2024-10-11 11:50:56 +08:00
parent faf3928028
commit aa8d8a7185
1 changed files with 14 additions and 13 deletions

View File

@ -42,12 +42,12 @@ export async function fetchAboutus() {
accept: "application/json"
};
const url = `${process.env.NEXT_PUBLIC_API_URL}aboutUs/`;
try {
const response = await fetch(url, { headers });
const result = await response.json();
// Sort the result by index
const sortedResult: AboutusProps[] = result.data.sort((a: any, b: any) => a.index - b.index);
@ -71,10 +71,10 @@ export async function fetchCourses() {
try {
const response = await fetch(url, { headers });
const result = await response.json();
const coursesArray: CoursesProps[] = result.data.map((course: CoursesProps) => ({
...course,
@ -88,7 +88,7 @@ export async function fetchCourses() {
return sortedCoursesArray;
} catch (error) {
throw error;
}
}
@ -99,14 +99,14 @@ export async function fetchCourse(id: string) {
};
const url = `${process.env.NEXT_PUBLIC_API_URL}course/${id}/`;
try {
const response = await fetch(url, { headers });
var result: CoursesProps = await response.json();
if (result.info_images && Array.isArray(result.info_images)) {
result.info_images.sort((a, b) => a.index - b.index);
@ -121,15 +121,16 @@ export async function fetchCourse(id: string) {
export async function fetchSettings() {
const headers: HeadersInit = {
accept: "application/json"
accept: "application/json",
cache: 'no-store'
};
const url = `${process.env.NEXT_PUBLIC_API_URL}setting/`;
try {
const response = await fetch(url, { headers });
const result: SettingsProps = await response.json();
return result;
}
catch (error) {