28 lines
662 B
JavaScript
28 lines
662 B
JavaScript
document.addEventListener('DOMContentLoaded', function() {
|
|
const routeId = document.getElementById('route').value;
|
|
|
|
async function updateRoute(routeData) {
|
|
try {
|
|
const response = await fetch(`/api/v1/admin/route/${routeId}`, {
|
|
method: 'PUT',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify(routeData)
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Network response was not ok');
|
|
}
|
|
|
|
const data = await response.json();
|
|
return data;
|
|
} catch (error) {
|
|
console.error('Error updating route:', error);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
// Export the function if needed
|
|
window.updateRoute = updateRoute;
|
|
}); |