Added API key authentication.

This commit is contained in:
2024-08-31 04:59:05 +02:00
parent da893c1a76
commit e8864ce35b
20 changed files with 514 additions and 28 deletions

View File

@@ -79,7 +79,7 @@ export async function post(path, data, options = {}) {
try {
const res = await fetch(`/api${path}${getQuery(options.query)}`, {
method: 'POST',
body: JSON.stringify(data),
body: data && JSON.stringify(data),
...postHeaders,
});
@@ -95,8 +95,6 @@ export async function post(path, data, options = {}) {
return body;
}
console.log(body.statusMessage);
showFeedback(false, options, body.statusMessage);
throw new Error(body.statusMessage);
} catch (error) {
@@ -109,7 +107,7 @@ export async function patch(path, data, options = {}) {
try {
const res = await fetch(`/api${path}${getQuery(options.query)}`, {
method: 'PATCH',
body: JSON.stringify(data),
body: data && JSON.stringify(data),
...postHeaders,
});
@@ -136,7 +134,7 @@ export async function del(path, options = {}) {
try {
const res = await fetch(`/api${path}${getQuery(options.query)}`, {
method: 'DELETE',
body: JSON.stringify(options.data),
body: options.data && JSON.stringify(options.data),
...postHeaders,
});