提交 5b0536fa authored 作者: 王绍森's avatar 王绍森

request方法增加配置

上级 b60f961c
...@@ -43,7 +43,7 @@ function checkStatus(response) { ...@@ -43,7 +43,7 @@ function checkStatus(response) {
* @param {object} [options] The options we want to pass to "fetch" * @param {object} [options] The options we want to pass to "fetch"
* @return {object} An object containing either "data" or "err" * @return {object} An object containing either "data" or "err"
*/ */
export default function request(url, options) { export default function request(url, options, config = {enableLoading: true}) {
const defaultOptions = { const defaultOptions = {
credentials: 'omit', credentials: 'omit',
mode: 'cors', mode: 'cors',
...@@ -78,7 +78,9 @@ export default function request(url, options) { ...@@ -78,7 +78,9 @@ export default function request(url, options) {
url = url + '?' + stringify(options); url = url + '?' + stringify(options);
} }
} }
if (config.enableLoading) {
Toast.loading('加载中....', 1); Toast.loading('加载中....', 1);
}
return fetch(url, newOptions).then(checkStatus) return fetch(url, newOptions).then(checkStatus)
.then(response => { .then(response => {
if (response.status === 202) { if (response.status === 202) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论