From ac056dfe5e16340dc3540fd2dfb98cee7fe5590d Mon Sep 17 00:00:00 2001 From: nestoralonso Date: Sat, 3 Oct 2020 10:07:28 -0500 Subject: [PATCH] Delete ApiUtil.js Delete uppercase variant of ApiUtil.js because there is an identical version of the file with camelcase name apiUtil.js and some operating systems don't allow that --- web/src/common/ApiUtil.js | 62 --------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 web/src/common/ApiUtil.js diff --git a/web/src/common/ApiUtil.js b/web/src/common/ApiUtil.js deleted file mode 100644 index 4962dab4a..000000000 --- a/web/src/common/ApiUtil.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* AJAX操作工具类 -*/ -import PromiseUtil from './promiseUtil'; -export function getJSON(url, data) { - const d = PromiseUtil.defer(); - fetch(url + serializeQuery(data)) - .then((data) => { - d.resolve(data.json()); - }) - .catch((error) => { - console.error(error); - d.reject(error); - }); - return d.promise; -} - -export function postJSON(url, data) { - const d = PromiseUtil.defer(); - fetch(url, { - method: 'POST', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - }, - body: JSON.stringify(data) - }) - .then((data) => { - - d.resolve(data.json()); - }) - .catch((error) => { - console.error(error); - d.reject(error); - }); - return d.promise; -} - -function serializeQuery (data = {}) { - data['__t'] = Date.now();// disable the cache - const queryArray = []; - - for (let key in data) { - queryArray.push(`${key}=${data[key]}`); - } - - const queryStr = queryArray.join('&'); - - return queryStr ? '?' + queryStr : ''; -} - -export function isApiSuccess (response) { - return response.status === 'success'; -} - -const apiUtil = { - getJSON, - postJSON, - isApiSuccess -}; - -export default apiUtil;