Fixed query build error & added api to landingpage

This commit is contained in:
2022-01-31 11:38:03 +01:00
parent 987bedc65f
commit 53c162eec5
4 changed files with 7 additions and 6 deletions

View File

@@ -8,6 +8,7 @@
<base href="{{.BasePath}}"> <base href="{{.BasePath}}">
<link rel="stylesheet" href="sass/index.css"> <link rel="stylesheet" href="sass/index.css">
<script src="js/api.js" type="text/javascript">
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

View File

@@ -1,4 +1,4 @@
const prefix = ""; const prefix = document.getElementsByTagName("base")[0].href;
async function unknownResponse(resp) { async function unknownResponse(resp) {
let json = await resp.json(); let json = await resp.json();
try { try {
@@ -18,10 +18,10 @@ function buildQuery(options) {
else if (element[1] instanceof Array) { else if (element[1] instanceof Array) {
element[1] = JSON.stringify(element[1]); element[1] = JSON.stringify(element[1]);
} }
query.push(`${element[0]}&${element[1]}`); query.push(`${element[0]}=${element[1]}`);
} }
}); });
return query.join("="); return query.join("&");
} }
async function login(username, password) { async function login(username, password) {
let result = await fetch(`${prefix}/api/login`, { let result = await fetch(`${prefix}/api/login`, {

File diff suppressed because one or more lines are too long

View File

@@ -19,10 +19,10 @@ function buildQuery(options: any[][]): string {
} else if (element[1] instanceof Array) { } else if (element[1] instanceof Array) {
element[1] = JSON.stringify(element[1]) element[1] = JSON.stringify(element[1])
} }
query.push(`${element[0]}&${element[1]}`) query.push(`${element[0]}=${element[1]}`)
} }
}); });
return query.join("=") return query.join("&")
} }
interface Author { interface Author {