Added basic comments.

This commit is contained in:
2023-06-11 05:32:02 +02:00
parent 9a9b92a6b1
commit 0d5744e3ff
26 changed files with 441 additions and 89 deletions

View File

@@ -15,7 +15,7 @@ function getQuery(data) {
}
export async function get(path, query = {}) {
const res = await fetch(`${path}${getQuery(query)}`);
const res = await fetch(`/api${path}${getQuery(query)}`);
const body = await res.json();
if (res.ok) {
@@ -26,7 +26,7 @@ export async function get(path, query = {}) {
}
export async function post(path, data, { query } = {}) {
const res = await fetch(`${path}${getQuery(query)}`, {
const res = await fetch(`/api${path}${getQuery(query)}`, {
method: 'POST',
body: JSON.stringify(data),
...postHeaders,
@@ -46,7 +46,7 @@ export async function post(path, data, { query } = {}) {
}
export async function patch(path, data, { query } = {}) {
const res = await fetch(`${path}${getQuery(query)}`, {
const res = await fetch(`/api${path}${getQuery(query)}`, {
method: 'PATCH',
body: JSON.stringify(data),
...postHeaders,
@@ -66,7 +66,7 @@ export async function patch(path, data, { query } = {}) {
}
export async function del(path, { data, query } = {}) {
const res = await fetch(`${path}${getQuery(query)}`, {
const res = await fetch(`/api${path}${getQuery(query)}`, {
method: 'DELETE',
body: JSON.stringify(data),
...postHeaders,

View File

@@ -2,3 +2,7 @@
export default function navigate(path) {
window.location.href = path;
}
export function reload() {
window.location.reload();
}