From 4d4e419990ca8fca2be4aef09b02fd4051e9740f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BF=A1=E9=91=AB-King?= Date: Thu, 11 Oct 2018 10:27:13 +0800 Subject: [PATCH] fix: request cache if pro site (#2519) --- src/utils/request.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/utils/request.js b/src/utils/request.js index ffad1ed9..90703f75 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -60,15 +60,17 @@ const cachedSave = (response, hashcode) => { * Requests a URL, returning a promise. * * @param {string} url The URL we want to request - * @param {object} [options] The options we want to pass to "fetch" + * @param {object} [option] The options we want to pass to "fetch" * @return {object} An object containing either "data" or "err" */ export default function request( url, - options = { - expirys: isAntdPro(), - } + option, ) { + const options = { + expirys: isAntdPro(), + ...option, + }; /** * Produce fingerprints based on url and parameters * Maybe url has the same parameters @@ -104,7 +106,7 @@ export default function request( } } - const expirys = options.expirys || 60; + const expirys = options.expirys && 60; // options.expirys !== false, return the cache, if (options.expirys !== false) { const cached = sessionStorage.getItem(hashcode); -- GitLab