23 lines
802 B
TypeScript
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);
|
|
}
|
|
}; |