Skip to content

Commit 423cc35

Browse files
committed
chore: updated types for showErrorMessage method
1 parent bc6fe41 commit 423cc35

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

template/src/screens/MainAppScreens/Users/slice.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const getUsers = createAsyncThunk('users/getUsers', async () => {
1515

1616
return users;
1717
} catch (error) {
18-
showErrorMessage(error);
18+
showErrorMessage(error as any);
1919
}
2020
});
2121

template/src/utilities/helperFunctions/miscellaneous.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ const showFlashMessage = (message: string, options = {}) => {
2222
};
2323

2424
export const showErrorMessage = (
25-
error: {response: {data: {message: string}}},
25+
error: {response: {data: {message: string}}} | {message: string} | string,
2626
options = {},
2727
) => {
28-
let errorMessage;
28+
let errorMessage: string | undefined;
2929
if (typeof error === 'string') {
3030
errorMessage = error;
3131
}
32-
if (error?.response?.data?.message) {
32+
if (typeof error === 'object' && 'response' in error && error.response?.data?.message) {
3333
errorMessage = error.response.data.message;
3434
}
3535
if (!errorMessage) {

0 commit comments

Comments
 (0)