chg: Use json while sending form for new url

This commit is contained in:
SinTan1729
2024-03-31 15:17:54 -05:00
parent 6659452c51
commit 99b5298cd8
4 changed files with 28 additions and 16 deletions

View File

@@ -168,14 +168,19 @@ const TD = (s, u) => {
const submitForm = () => {
const form = document.forms.namedItem("new-url-form");
const longUrl = form.elements["longUrl"];
const shortUrl = form.elements["shortUrl"];
const data ={
"longlink": form.elements["longUrl"].value,
"shortlink": form.elements["shortUrl"].value,
};
const url = prepSubdir("/api/new");
fetch(url, {
method: "POST",
body: `${longUrl.value};${shortUrl.value}`
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
})
.then(res => {
if (!res.ok) {