From 290819de09c0bb1620b0b71a3fd73e5e745220f3 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 23 May 2023 13:15:29 +0200 Subject: [PATCH] Created first api-calls #1 --- Website/apiConnector.js | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/Website/apiConnector.js b/Website/apiConnector.js index 9e40e55..ad41a13 100644 --- a/Website/apiConnector.js +++ b/Website/apiConnector.js @@ -1,8 +1,35 @@ const apiUri = "http://localhost:5177"; +function GetAvailableControllers(){ + var uri = apiUri + "/GetAvailableControllers"; + const response = await fetch(uri, { + method: 'GET', + headers: { + 'Accept': 'application/json' + } + }).catch(error => console.error('Unable to get items.', error)); + return await response.json(); +} + + function GetTasks(){ - var getTaskUri = apiUri + "/Tasks/GetList"; - fetch(getTaskUri) - .then(response => response.json()) - .catch(error => console.error('Unable to get items.', error)); + var uri = apiUri + "/Tasks/GetList"; + const response = await fetch(uri, { + method: 'GET', + headers: { + 'Accept': 'application/json' + } + }).catch(error => console.error('Unable to get items.', error)); + return await response.json(); +} + +async function GetSettings(){ + var uri = apiUri + "/Settings/Get"; + const response = await fetch(uri, { + method: 'GET', + headers: { + 'Accept': 'application/json' + } + }).catch(error => console.error('Unable to get items.', error)); + return await response.json(); } \ No newline at end of file