53 lines
No EOL
1.6 KiB
JavaScript
53 lines
No EOL
1.6 KiB
JavaScript
async function ping(){
|
|
fetch ('http://127.0.0.1:5180/api/ping')
|
|
.then(data => {
|
|
console.log(data);
|
|
});
|
|
}
|
|
async function setBaseDataHorseAPI(id, basedata) {
|
|
try {
|
|
console.log("Setting horse data");
|
|
console.log("ID:", id); // Log ID to ensure it's received correctly
|
|
console.log("Basedata:", basedata); // Log the entire horse data to check
|
|
|
|
const url = `http://127.0.0.1:5180/api/setHorseBasicData/id=${id}`;
|
|
|
|
// Wait for the API call to complete
|
|
const response = await fetch(url, {
|
|
method: 'POST',
|
|
body: JSON.stringify(basedata),
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
}
|
|
});
|
|
|
|
const data = await response; // Wait for the response from the API
|
|
console.log("API Response:", data); // Log the response from the API
|
|
|
|
} catch (error) {
|
|
console.error("Error setting horse data: " + error.message);
|
|
}
|
|
}
|
|
async function getHorseAPI(id) {
|
|
var horseData;
|
|
const url = 'http://127.0.0.1:5180/api/getHorseInfo/id=' + id;
|
|
await fetch(url)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
horseData = data;
|
|
});
|
|
return horseData;
|
|
}
|
|
async function setHorsePedigreeAPI(id, pedigreeData)
|
|
{
|
|
const url = `http://127.0.0.1:5180/api/setHorsePedigree/id=${id}`;
|
|
const response = await fetch(url, {
|
|
method: 'POST',
|
|
body: JSON.stringify(pedigreeData),
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
}
|
|
});
|
|
const data = await response;
|
|
return data;
|
|
} |