From e762cf77b3bb48c2086c67fe8c51bf376b50f73d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AF=9B=E5=91=86?= Date: Mon, 16 May 2022 14:19:46 +0800 Subject: [PATCH] Adding Canceler parameters config and request (#4711) Co-authored-by: Jay --- index.d.ts | 2 +- lib/cancel/CancelToken.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index cd3a1f8577..1c536a2cb4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -210,7 +210,7 @@ export interface Cancel { } export interface Canceler { - (message?: string): void; + (message?: string, config?: AxiosRequestConfig, request?: any): void; } export interface CancelTokenStatic { diff --git a/lib/cancel/CancelToken.js b/lib/cancel/CancelToken.js index 07ec10e3b2..c2fe64c7fd 100644 --- a/lib/cancel/CancelToken.js +++ b/lib/cancel/CancelToken.js @@ -49,13 +49,13 @@ function CancelToken(executor) { return promise; }; - executor(function cancel(message) { + executor(function cancel(message, config, request) { if (token.reason) { // Cancellation has already been requested return; } - token.reason = new CanceledError(message); + token.reason = new CanceledError(message, config, request); resolvePromise(token.reason); }); }