From 209a798d46fed65a52a40bc5fa8dd97b7e620ddf Mon Sep 17 00:00:00 2001 From: Aaron Chong Date: Thu, 3 Oct 2024 16:53:42 +0800 Subject: [PATCH] Return promise for axios request and response Signed-off-by: Aaron Chong --- packages/dashboard/src/services/rmf-api.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/dashboard/src/services/rmf-api.ts b/packages/dashboard/src/services/rmf-api.ts index 7ebebe946..9b3b63dd2 100644 --- a/packages/dashboard/src/services/rmf-api.ts +++ b/packages/dashboard/src/services/rmf-api.ts @@ -117,6 +117,10 @@ export class DefaultRmfApi implements RmfApi { }, (error) => { console.error(`Axios request error: ${error}`); + if (error && error.response && error.response.status && error.response.status === 401) { + window.location.href = '/'; + } + return Promise.reject(error); }, ); axiosInst.interceptors.response.use( @@ -126,6 +130,7 @@ export class DefaultRmfApi implements RmfApi { if (error && error.response && error.response.status && error.response.status === 401) { window.location.href = '/'; } + return Promise.reject(error); }, ); const apiConfig = new Configuration({