manifest + fav icon + title page
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { API_BASE_URL } from "@/config/const";
|
||||
import { AboutResponse, Restaurant } from "./(Main)/about/types/Types";
|
||||
|
||||
export async function getRestaurant(slug: string): Promise<Restaurant> {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${API_BASE_URL}/public/restaurants/${slug}`,
|
||||
{
|
||||
cache: "no-store",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
if (response.status === 404) {
|
||||
throw new Error("RESTAURANT_NOT_FOUND");
|
||||
}
|
||||
throw new Error(`Failed to fetch restaurant: ${response.status}`);
|
||||
}
|
||||
|
||||
const data: AboutResponse = await response.json();
|
||||
|
||||
if (!data.success || !data.data) {
|
||||
throw new Error("RESTAURANT_NOT_FOUND");
|
||||
}
|
||||
|
||||
return data.data;
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message === "RESTAURANT_NOT_FOUND") {
|
||||
throw error;
|
||||
}
|
||||
throw new Error(`Failed to fetch restaurant data: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user