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