Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit bf68b6f

Browse files
fix: error message JSON body was not displaying
1 parent 96a8512 commit bf68b6f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/features/Apiexplorer/SubscribeRenderer/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ function SubscribeRenderer<T extends TSocketSubscribableEndpointNames>({
3232
const [is_not_valid, setIsNotValid] = useState(false);
3333

3434
useEffect(() => {
35-
if (error && error.code === 'AuthorizationRequired') {
35+
if (
36+
error &&
37+
typeof error === 'object' &&
38+
'code' in error &&
39+
error.code === 'AuthorizationRequired'
40+
) {
3641
setToggleModal(true);
3742
}
3843
}, [error]);

src/hooks/useSubscription/index.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ import {
66
} from '@site/src/configs/websocket/types';
77
import { useCallback, useState } from 'react';
88

9-
type TError = {
10-
code?: string;
11-
message?: string;
12-
};
13-
149
const useSubscription = <T extends TSocketSubscribableEndpointNames>(name: T) => {
1510
const [is_loading, setIsLoading] = useState(false);
1611
const [is_subscribed, setSubscribed] = useState(false);
17-
const [error, setError] = useState<TError>();
12+
const [error, setError] = useState<unknown>();
1813
const [data, setData] = useState<TSocketResponseData<T>>();
1914
const [full_response, setFullResponse] = useState<TSocketResponse<T>>();
2015
const [subscriber, setSubscriber] = useState<{ unsubscribe?: VoidFunction }>();
@@ -30,7 +25,7 @@ const useSubscription = <T extends TSocketSubscribableEndpointNames>(name: T) =>
3025
);
3126

3227
const onError = useCallback((response: TSocketResponse<T>) => {
33-
setError(response.error);
28+
setError(response);
3429
setIsLoading(false);
3530
setFullResponse(null);
3631
}, []);

0 commit comments

Comments
 (0)