Full commit for review

This commit is contained in:
2023-05-10 20:43:45 +02:00
parent bb6db9d523
commit 513772dd1e
47 changed files with 7956 additions and 1 deletions

58
webapp/scripts/fetcher.js Normal file
View File

@@ -0,0 +1,58 @@
async function get(url, token) {
const response = await fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
authorization: `${token}`
},
});
const data = await response.json();
return { status: response.status, data: data };
}
async function post(url, json, token) {
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
authorization: `${token}`
},
body: JSON.stringify(json),
});
const data = await response.json();
return { status: response.status, data: data };
}
async function patch(url, json, token) {
const response = await fetch(url, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
authorization: `${token}`
},
body: JSON.stringify(json),
});
const data = await response.json();
return { status: response.status, data: data };
}
async function put(url, json, token) {
const response = await fetch(url, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
authorization: `${token}`
},
body: JSON.stringify(json),
});
const data = await response.json();
return { status: response.status, data: data };
}