Skip to content

Commit

Permalink
Fail early if cannot get a OK response when submitting user phone number
Browse files Browse the repository at this point in the history
  • Loading branch information
pH-7 committed May 5, 2024
1 parent 9e7a4ee commit 650e91b
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions client/components/modals/NotifyMeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,21 @@ export const NotifyMeModal: React.FC<NotifyMeModalProps> = ({

const handleSubmit = async () => {
try {
const formData = new FormData();
formData.append("entry.PHONE_NUMBER_FIELD_ID", phoneNumber);

await fetch(AppInfo.GOOGLE_FORM_WAITING_LIST_URL, {
method: "POST",
mode: "no-cors",
body: formData,
});
const formData = new FormData();
formData.append("entry.PHONE_NUMBER_FIELD_ID", phoneNumber);

const response = await fetch(AppInfo.GOOGLE_FORM_WAITING_LIST_URL, {
method: "POST",
mode: "no-cors",
body: formData,
});
// fail-early if response is't OK
if (!response.ok) {
throw new Error(
"We couldn't submit your phone number. Please try again.",
);
}

onSubmitSuccess();
//setPhoneNumber("");
} catch (error) {
Expand Down

0 comments on commit 650e91b

Please sign in to comment.