change ternary operator for fetch

This commit is contained in:
BlasenhauerJ 2022-11-18 15:30:32 +01:00
parent fa5719db7f
commit f1e614fae6
2 changed files with 5 additions and 6 deletions

View File

@ -44,6 +44,7 @@ class darkMode {
this.htmlEl = document.querySelector("html");
this.darkToggleEl = document.querySelector("[dark-toggle]");
this.darkToggleLabel = document.querySelector("[dark-toggle-label]");
this.csrf = document.querySelector("input#csrf_token");
this.init();
}
@ -63,14 +64,13 @@ class darkMode {
async saveMode() {
const isDark = this.darkToggleEl.checked ? "true" : "false";
console.log(isDark);
const data = {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({ darkmode: isDark }),
body: JSON.stringify({ darkmode: isDark, csrf_token: this.csrf.value }),
};
const send = await fetch(`${location.href}/darkmode}`, data);
}

View File

@ -217,10 +217,9 @@ class FetchLogs {
async getLogsFromToDate() {
const response = await fetch(
`${location.href}/${this.instanceName}?from_date=${this.fromDate}` +
this.toDate
? `?to_date=${this.toDate}`
: ""
`${location.href}/${this.instanceName}?from_date=${this.fromDate}${
this.toDate ? `?to_date=${this.toDate}` : ``
}`
);
if (response.status === 200) {