This commit is contained in:
zadit frontend
2024-08-01 07:49:04 +00:00
parent e424195d2e
commit a158e44071
6 changed files with 191 additions and 19 deletions

View File

@@ -14,7 +14,55 @@ export async function getOwnedCafes(userId) {
"Content-Type": "application/json",
Authorization: `Bearer ${getAuthToken()}`,
},
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch cart details");
}
const cafes = await response.json();
return cafes;
} catch (error) {
console.error("Error:", error);
}
}
export async function createCafe(userId) {
try {
const response = await fetch(
`${API_BASE_URL}/cafe/get-cafe-by-ownerId/` + userId,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${getAuthToken()}`,
},
}
);
if (!response.ok) {
throw new Error("Failed to fetch cart details");
}
const cafes = await response.json();
return cafes;
} catch (error) {
console.error("Error:", error);
}
}
export async function updateCafe(userId) {
try {
const response = await fetch(
`${API_BASE_URL}/cafe/get-cafe-by-ownerId/` + userId,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${getAuthToken()}`,
},
}
);
if (!response.ok) {