@dfeidao/atom-mobile
Advanced tools
Comparing version 4.6.201905151327 to 4.6.201905161817
/** | ||
* @module msg服务请求 | ||
*/ | ||
export default function post<T>(url: string, body: string | FormData): Promise<T>; | ||
export default function get<T>(url: string, body: string, disable_cache: boolean): Promise<T>; |
@@ -10,4 +10,21 @@ "use strict"; | ||
const _global_1 = __importDefault(require("./_global")); | ||
async function post(url, body) { | ||
const ret = await fetch(`${_global_1.default.host}/${url}`, { | ||
function generateRequestUrl(url, body, disable_cache) { | ||
const usp = new URLSearchParams(); | ||
const query_param = body || {}; | ||
for (const k in query_param) { | ||
if (query_param.hasOwnProperty(k)) { | ||
usp.append(k, query_param[k]); | ||
} | ||
} | ||
let query = usp.toString(); | ||
// let query = obj2query(options.query || {}); | ||
if (disable_cache) { | ||
const cacheBust = String(Date.now()); | ||
query += query ? '&' + cacheBust : cacheBust; | ||
} | ||
const separator = url.indexOf('?') > -1 ? '&' : '?'; | ||
return query ? url + separator + query : url; | ||
} | ||
async function get(url, body, disable_cache) { | ||
const ret = await fetch(`${_global_1.default.host}/${generateRequestUrl(url, body, disable_cache)}`, { | ||
body, | ||
@@ -47,2 +64,2 @@ credentials: 'include', | ||
} | ||
exports.default = post; | ||
exports.default = get; |
{ | ||
"name": "@dfeidao/atom-mobile", | ||
"version": "4.6.201905151327", | ||
"version": "4.6.201905161817", | ||
"description": "原子操作", | ||
@@ -5,0 +5,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
150204
4840