Skip to content

Commit

Permalink
Add optional chaining to resolve undefined errors (#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellemaxwell authored Mar 1, 2024
1 parent e9ea9fe commit 42bfe4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions web/gds-user-ui/src/hooks/useFetchAttention.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const useFetchAttention = () => {
try {
setAuthorization();
const result = await axiosInstance.get('/attention');
if (result.status === 200) {
setAttentionResponse(result.data);
if (result?.status === 200) {
setAttentionResponse(result?.data);
} else {
setAttentionResponse([]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { PayloadDTO } from 'modules/dashboard/certificate/types';
export const getCertificateStepService = async (payload: PayloadDTO) => {
const { key } = payload;
const response = await axiosInstance.get(`/register?step=${key}`);
return response.data;
return response?.data;
};

export const postCertificateStepService = async (payload: any) => {
Expand All @@ -15,11 +15,11 @@ export const postCertificateStepService = async (payload: any) => {
...payload
}
});
return response.data;
return response?.data;
};
export const deleteCertificateStepService = async (payload: any) => {
if (!payload) return;
const url = payload?.step ? `/register?step=${payload?.step}` : '/register';
const response = await axiosInstance.delete(url);
return response.data;
return response?.data;
};

0 comments on commit 42bfe4b

Please sign in to comment.