Files
Dwinzo_Demo/app/src/services/factoryBuilder/aisle/createAisleApi.ts

37 lines
1.0 KiB
TypeScript
Raw Normal View History

2025-06-10 15:28:23 +05:30
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const createAisleApi = async (
aisleUuid: string,
points: any,
type: Object,
2025-06-23 09:37:53 +05:30
projectId: string,
versionId: string,
2025-06-10 15:28:23 +05:30
) => {
try {
const response = await fetch(`${url_Backend_dwinzo}/api/V1/UpsertAisle`, {
method: "POST",
headers: {
Authorization: "Bearer <access_token>", // Replace with actual token
"Content-Type": "application/json",
token: localStorage.getItem("token") || "", // Coerce null to empty string
refresh_token: localStorage.getItem("refreshToken") || "",
},
2025-06-23 09:37:53 +05:30
body: JSON.stringify({ aisleUuid, points, type, projectId, versionId }),
2025-06-10 15:28:23 +05:30
});
if (!response.ok) {
throw new Error("Failed to add project");
}
const result = await response.json();
// console.log("result: ", result);
return result;
} catch (error) {
if (error instanceof Error) {
2025-06-23 09:37:53 +05:30
console.log(error.message);
2025-06-10 15:28:23 +05:30
} else {
2025-06-23 09:37:53 +05:30
console.log("An unknown error occurred");
2025-06-10 15:28:23 +05:30
}
}
};