From 18f636ec8c348ef12b41ee0418ecbd1242897541 Mon Sep 17 00:00:00 2001 From: Kalyax Date: Mon, 7 Nov 2022 17:50:34 +0100 Subject: [PATCH] axios --- index.html | 7 +++++-- main.js | 2 -- src/api_requests.js | 5 +++++ src/main.js | 6 ++++++ 4 files changed, 16 insertions(+), 4 deletions(-) delete mode 100644 main.js create mode 100644 src/api_requests.js create mode 100644 src/main.js diff --git a/index.html b/index.html index 622b5b9..c4a5b05 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,10 @@ Domotique -

AH!

- +
+ DOMOTIQUE 3000 +
+

t

+ diff --git a/main.js b/main.js deleted file mode 100644 index ac6be2d..0000000 --- a/main.js +++ /dev/null @@ -1,2 +0,0 @@ -import './src/style.css'; -//import axios from 'axios'; diff --git a/src/api_requests.js b/src/api_requests.js new file mode 100644 index 0000000..6c41c8f --- /dev/null +++ b/src/api_requests.js @@ -0,0 +1,5 @@ +import axios from "axios"; + +export default async function getTemp(){ + return await axios.get("/api/temp.php"); +} \ No newline at end of file diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..4f5034d --- /dev/null +++ b/src/main.js @@ -0,0 +1,6 @@ +import './style.css'; +import getTemp from './api_requests.js'; +getTemp() +.then((data) => { + document.getElementById("test").innerHTML = data; +}) \ No newline at end of file