fix: handle undefined slug and doctorId in cache functions

This commit is contained in:
hamed
2026-07-07 11:47:44 +03:30
parent df7fbb7530
commit 73c10f53ec
2 changed files with 3 additions and 0 deletions
+1
View File
@@ -11,6 +11,7 @@ import { imageUrl } from "@/helper";
const API_URL = process.env.NEXT_PUBLIC_API_URL;
const getClinic = cache(async (slug) => {
if (!slug || slug === "undefined") return null;
const res = await fetch(`${API_URL}/api/v1/clinic/${slug}`, {
next: { revalidate: 3600, tags: [`clinic-${slug}`] },
});
+2
View File
@@ -11,6 +11,7 @@ const API_URL = process.env.NEXT_PUBLIC_API_URL;
const FALLBACK_IMG = "https://nobat724.com/assets/images/logo.png";
const getDoctor = cache(async (slug) => {
if (!slug || slug === "undefined") return null;
const res = await fetch(`${API_URL}/api/v1/doctor/${slug}`, {
next: { revalidate: 3600, tags: [`doctor-${slug}`] },
});
@@ -21,6 +22,7 @@ const getDoctor = cache(async (slug) => {
});
const getDoctorAddresses = cache(async (doctorId) => {
if (!doctorId) return [];
try {
const res = await fetch(`${API_URL}/api/v1/clinic-pro/doctor-addresses/${doctorId}`, {
next: { revalidate: 3600, tags: [`doctor-addresses-${doctorId}`] },