visuddhinanda 2 лет назад
Родитель
Сommit
494c9566d5
1 измененных файлов с 2 добавлено и 50 удалено
  1. 2 50
      dashboard/src/utils.ts

+ 2 - 50
dashboard/src/utils.ts

@@ -1,53 +1,5 @@
-export function ApiFetch(
-  url: string,
-  method = "GET",
-  data?: any
-): Promise<Response> {
-  const apiHost = process.env.REACT_APP_API_HOST;
-  interface ajaxParam {
-    method: string;
-    body?: string;
-    headers?: any;
-  }
-  let param: ajaxParam = {
-    method: method,
-  };
-  if (typeof data !== "undefined") {
-    param.body = JSON.stringify(data);
-  }
-  if (localStorage.getItem("token")) {
-    param.headers = { token: localStorage.getItem("token") };
-  }
-  return new Promise((resolve, reject) => {
-    let apiUrl = apiHost + url;
-    console.log("api", apiUrl);
-    fetch(apiUrl, param)
-      .then((response) => response.json())
-      .then((response) => {
-        resolve(response);
-      })
-      .catch((error) => {
-        reject(error);
-      });
-  });
-}
-
-export function ApiGetText(url: string): Promise<String> {
-  const apiHost = process.env.REACT_APP_API_HOST
-    ? process.env.REACT_APP_API_HOST
-    : "http://localhost/api";
-  return new Promise((resolve, reject) => {
-    let apiUrl = apiHost + url;
-    console.log("api", apiUrl);
-    fetch(apiUrl)
-      .then((response) => response.text())
-      .then((response) => {
-        resolve(response);
-      })
-      .catch((error) => {
-        reject(error);
-      });
-  });
+export function fullUrl(url: string): string {
+  return process.env.REACT_APP_WEB_HOST + process.env.PUBLIC_URL + url;
 }
 
 export function PaliToEn(pali: string): string {