Handvask / handvask

async function should have await expression JS-0116
Bug risk
Minor
a year agoa year old
Found async function without any await expressions
 52    });
 53}
 54
 55export async function asyncHttp<T = SuccessResponse>(request: Request) { 56  return fetch(request) 57    .then((r) => r.json()) 58    .then((data) => { 59      if (Object.prototype.hasOwnProperty.call(data, "dd")) { 60        window.dispatchEvent(new CustomEvent("__dd", { detail: data.dd })); 61      } else if (Object.prototype.hasOwnProperty.call(data, "whoops")) { 62        window.dispatchEvent( 63          new CustomEvent("__whoops", { detail: data.whoops }) 64        ); 65      } else if (Object.prototype.hasOwnProperty.call(data, "redirect")) { 66        document.location = data.redirect; 67      } 68      return data as T; 69    }); 70} 71
 72export function httpGet<T = SuccessResponse>(
 73  url: string,
Found async function without any await expressions
109  http<T>(r, callback);
110}
111
112export async function asyncHttpGet<T = SuccessResponse>(url: string) {113  const r = new Request(url, {114    method: "GET",115    headers: {116      "X-Requested-With": "XMLHttpRequest",117    },118  });119  return asyncHttp<T>(r);120}121
122export async function asyncHttpPost<T = SuccessResponse>(
123  url: string,
Found async function without any await expressions
119  return asyncHttp<T>(r);
120}
121
122export async function asyncHttpPost<T = SuccessResponse>(123  url: string,124  data: Record<string, unknown>125) {126  const r = new Request(url, {127    method: "POST",128    headers: {129      "Content-Type": "application/json",130      "X-Requested-With": "XMLHttpRequest",131    },132    body: JSON.stringify(data),133  });134  return asyncHttp<T>(r);135}