Skip to content

Commit

Permalink
feat(search-form): implement basic error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
alanrochagomes committed Nov 7, 2024
1 parent 9d04978 commit aa2002f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/search-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ export default function SearchForm(props: SearchFormProps) {
body: formData,
});

const data: SearchResult[] = await response.json();
props.onSearchResultsReady(data);
if (response.status === 200) {
const data: SearchResult[] = await response.json();
props.onSearchResultsReady(data);
} else {
// TODO: Implement toastify to show a beautiful error message
alert("Ocorreu um erro na busca. Tente novamente mais tarde.");
}

setIsLoading(false);
}
Expand Down

0 comments on commit aa2002f

Please sign in to comment.