This commit is contained in:
2024-01-30 18:47:57 +01:00
parent 5583bc2b60
commit 794b50e041
2 changed files with 21 additions and 0 deletions

View File

@ -13,6 +13,17 @@
document.getElementById('submit-button').disabled = !allFilled;
}
function getBearerToken(callback) {
fetch('/get_token')
.then(response => response.json())
.then(data => {
callback(data.token);
})
.catch(error => {
console.error('Fehler beim Abrufen des Tokens:', error);
});
}
function addNutritionEntry() {
const form = document.getElementById('nutrition-form');
@ -20,6 +31,9 @@
fetch('/add_nutrition', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + token
},
body: formData
}).then(response => {
// Behandlung der Serverantwort