Skip to content

Commit

Permalink
fix: use unsealed result should fail if request fails
Browse files Browse the repository at this point in the history
  • Loading branch information
JuroUhlar committed Apr 20, 2024
1 parent d0d5a1a commit 60e8cea
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/client/hooks/useUnsealedResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ export const useUnsealedResult = (sealedResult?: string) => {
return useQuery<EventResponse>({
queryKey: ['event', sealedResult],
queryFn: async () => {
return fetch('/api/decrypt', {
const response = await fetch('/api/decrypt', {
method: 'POST',
body: JSON.stringify({ sealedResult }),
}).then((res) => res.json());
});
if (response.status !== 200) {
throw new Error('Failed to unseal result: ' + response.statusText);
}
return await response.json();
},
enabled: Boolean(sealedResult),
});
Expand Down

0 comments on commit 60e8cea

Please sign in to comment.