From 6284abfa0693c983e9378b2d074c095262aac7bd Mon Sep 17 00:00:00 2001 From: IVLIU Date: Wed, 16 Oct 2019 09:29:16 +0800 Subject: [PATCH] custom timeout prompt copy (#2275) * style: ui * feat: custom timeout txtx * feat: custom timeout txtx --- index.d.ts | 1 + lib/adapters/xhr.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 8490672664..065f34bd79 100644 --- a/index.d.ts +++ b/index.d.ts @@ -49,6 +49,7 @@ export interface AxiosRequestConfig { paramsSerializer?: (params: any) => string; data?: any; timeout?: number; + timeoutErrorMessage?: string; withCredentials?: boolean; adapter?: AxiosAdapter; auth?: AxiosBasicCredentials; diff --git a/lib/adapters/xhr.js b/lib/adapters/xhr.js index 519e3c3745..7e8668dade 100644 --- a/lib/adapters/xhr.js +++ b/lib/adapters/xhr.js @@ -88,7 +88,11 @@ module.exports = function xhrAdapter(config) { // Handle timeout request.ontimeout = function handleTimeout() { - reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', + var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded'; + if (config.timeoutErrorMessage) { + timeoutErrorMessage = config.timeoutErrorMessage; + } + reject(createError(timeoutErrorMessage, config, 'ECONNABORTED', request)); // Clean up request