document.getElementById('calculateButton').addEventListener('click', function() {
var fromCity = document.getElementById('fromCity').value;
var toCity = document.getElementById('toCity').value;
var weight = document.getElementById('weight').value;
var apiUrl = 'https://api.ati.su/v1/calculate'; // Примерный URL API ATI.SU
var apiKey = 'YOUR_API_KEY'; // Ваш API ключ
var data = {
from: fromCity,
to: toCity,
weight: weight
};
fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + apiKey
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => {
document.getElementById('result').textContent = 'Стоимость: ' + result.cost;
})
.catch(error => console.error('Error:', error));
});