Files
universal_is/client/src/actions/map.ts
2024-11-15 17:00:23 +09:00

23 lines
802 B
TypeScript

import { Coordinate } from "ol/coordinate";
import { IGeometryType } from "../interfaces/map";
export const uploadCoordinates = async (coordinates: Coordinate[], type: IGeometryType) => {
try {
const response = await fetch(`${import.meta.env.VITE_API_EMS_URL}/nodes`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ coordinates, object_id: 1, type: type }) // Replace with actual object_id
});
if (response.ok) {
const data = await response.json();
console.log('Node created:', data);
} else {
console.error('Failed to upload coordinates');
}
} catch (error) {
console.error('Error:', error);
}
};