From 26ca666bcf20c5aef81582562511677a6e043ae1 Mon Sep 17 00:00:00 2001 From: mohammedcifci78 Date: Wed, 7 Feb 2024 12:25:34 +0100 Subject: [PATCH] jjsonFetch --- script.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 script.js 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); + + +}