api url params 中支持复杂对象

This commit is contained in:
liaoxuezhi 2019-12-09 16:19:16 +08:00
parent 2518dbedcc
commit 912d3816b3

View File

@ -67,7 +67,18 @@ export function buildApi(
}
const raw = (api.url = api.url || '');
api.url = tokenize(api.url, data, '| url_encode');
const idx = api.url.indexOf('?');
if (~idx) {
const hashIdx = api.url.indexOf('#');
const params = qs.parse(
api.url.substring(idx + 1, ~hashIdx ? hashIdx : undefined)
);
api.url =
api.url.substring(0, idx + 1) +
qsstringify(dataMapping(params, data)) +
(~hashIdx ? api.url.substring(hashIdx) : '');
}
if (ignoreData) {
return api;