this is my layout:
export default async function ClientLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<>
<Header />
<main>{children}</main>
<Footer />
</>
);
}
export default async function Header() {
const departments = await fetchDepartments();
return (
<header className={styles.navbar}>
<nav className={`${styles.container} container`}>
<Link href={"/"} className={styles.logo}>
<Image src={logo} priority={true} alt="logo" />
</Link>
<DepartmentsSelectContainer />
<Links />
<div className={styles.bookingBtn}>
<Link className={`btn yellow sm`} href={"/contacts"}>
Запис на прийом
</Link>
</div>
</nav>
</header>
);
}
export default async function Footer() {
const departments = await fetchDepartments();
return <div>currently empty</div>;
}
and my request function:
export async function fetchDepartments() {
const first = Date.now();
const data = await fetch(`${basicUrl}/departments`);
const second = Date.now();
console.log(second - first);
const parsedData = await data.json();
console.log("parsedData", parsedData);
return parsedData;
}
so my problem is that my request isn't cached and it is executed 2 times. I also tried checking in my API if it really duplicates and it is.
How do i fix this, so Request Memoization cache data and the follovig requests will use cached data?