Require template literals instead of string concatenation JS-0246
Anti-pattern
Minor
5 months ago2 years old
Unexpected string concatenation
119      method,
120      headers: {
121        "Content-Type": "application/json",
122        Authorization: "Bearer " + (await getCookie("tokenValue")),123      },
124    },
125  );
Unexpected string concatenation
114/* This is an example for calling this function: fetchPage("api/page/", "GET", page) */
115export async function fetchPage(url, method, page) {
116  const res = await fetch(
117    "http://" + location.hostname + ":8080/" + url + page,118    {
119      method,
120      headers: {
Unexpected string concatenation
 97    method,
 98    headers: {
 99      "Content-Type": "application/json",
100      Authorization: "Bearer " + (await getCookie("tokenValue")),101    },
102    body: JSON.stringify(body),
103  });
Unexpected string concatenation
 933. The function returns a json object of the fetched data. */
 94
 95export async function fetcher(url, method, body) {
 96  const res = await fetch("http://" + location.hostname + ":8080/" + url, { 97    method,
 98    headers: {
 99      "Content-Type": "application/json",
Unexpected string concatenation
 50  document.cookie.split(";").forEach(function (c) {
 51    document.cookie = c
 52      .replace(/^ +/, "")
 53      .replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); // Sets every cookie as expired to delete them 54  });
 55  await goto("/");
 56  location.reload();