mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-03 20:48:49 +08:00
api 如果设置了 dataType 直接在 amis 就处理好了
This commit is contained in:
parent
d9ad07d50a
commit
ddc1817d60
@ -178,16 +178,28 @@ export function wrapFetcher(
|
||||
return function(api, data, options) {
|
||||
api = buildApi(api, data, options) as ApiObject;
|
||||
|
||||
api.requestAdaptor && (api = api.requestAdaptor(api) || api);
|
||||
|
||||
if (api.data && (hasFile(api.data) || api.dataType === 'form-data')) {
|
||||
api.data = object2formData(api.data, api.qsOptions);
|
||||
} else if (api.data && api.dataType === 'form') {
|
||||
} else if (
|
||||
api.data &&
|
||||
typeof api.data !== 'string' &&
|
||||
api.dataType === 'form'
|
||||
) {
|
||||
api.data = qsstringify(api.data, api.qsOptions) as any;
|
||||
api.headers = api.headers || (api.headers = {});
|
||||
api.headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
} else if (
|
||||
api.data &&
|
||||
typeof api.data !== 'string' &&
|
||||
api.dataType === 'json'
|
||||
) {
|
||||
api.data = JSON.stringify(api.data) as any;
|
||||
api.headers = api.headers || (api.headers = {});
|
||||
api.headers['Content-Type'] = 'application/json';
|
||||
}
|
||||
|
||||
api.requestAdaptor && (api = api.requestAdaptor(api) || api);
|
||||
|
||||
if (typeof api.cache === 'number' && api.cache > 0) {
|
||||
const apiCache = getApiCache(api);
|
||||
return wrapAdaptor(
|
||||
|
Loading…
Reference in New Issue
Block a user