commit 26ca666bcf20c5aef81582562511677a6e043ae1 Author: mohammedcifci78 Date: Wed Feb 7 12:25:34 2024 +0100 jjsonFetch diff --git a/script.js b/script.js new file mode 100644 index 0000000..179d27c --- /dev/null +++ b/script.js @@ -0,0 +1,23 @@ +window.addEventListener("load", function () { + fetch("https://garden.inajar.nl/api/battery_voltage_events/?format=json", { + headers: { + Authorization: "Token 33bb3b42452306c58ecedc3c86cfae28ba22329c" //het token van het link zodat we authorization hebben .... + }, + mode: "cors", + }) + .then(response => { + if (!response.ok) { + throw new Error(`Network response was not ok: ${response.status}`); + } + return response.json(); + }) + .then(loadData) + .catch(error => console.error('Error fetching data:', error)); +}); + +function loadData(data) { + apiData = data; + console.log("Data loaded:", apiData); + + +}