Skip to content

NVR with realtime local object detection for IP cameras

guard clause for api error (#11436)

Josh Hawkinsbca01cb43c90
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";
}