From bca01cb43c906d471762021173ffedcd1a6b0f4a Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Sun, 19 May 2024 18:08:05 -0500 Subject: [PATCH] guard clause for api error (#11436) --- web/src/api/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/src/api/index.tsx b/web/src/api/index.tsx index 1d85cb1d8d..3ac8806c72 100644 --- a/web/src/api/index.tsx +++ b/web/src/api/index.tsx @@ -25,7 +25,10 @@ export function ApiProvider({ children, options }: ApiProviderType) { return axios.get(path, { params }).then((res) => res.data); }, onError: (error, _key) => { - if ([401, 302, 307].includes(error.response.status)) { + if ( + error.response && + [401, 302, 307].includes(error.response.status) + ) { window.location.href = error.response.headers.get("location") ?? "login"; }