We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 90b6abc commit 72c0a2aCopy full SHA for 72c0a2a
1 file changed
apps/web/src/hooks/useFindSession.ts
@@ -1,10 +1,11 @@
1
-import type { Session } from '@opendatacapture/schemas/session';
+import { type Session, $Session } from '@opendatacapture/schemas/session';
2
import axios from 'axios';
3
4
export const sessionInfo = async (sessionId: string): Promise<null | Session> => {
5
try {
6
const response = await axios.get(`/v1/sessions/${sessionId}`);
7
- return response.data ? (response.data as Session) : null;
+ const parsedResult = $Session.safeParse(response.data);
8
+ return parsedResult.success ? parsedResult.data : null;
9
} catch (error) {
10
console.error('Error fetching session:', error);
11
throw error;
0 commit comments