Open
Conversation
| const emailEncoded = encodeURIComponent(email) | ||
| const url = baseURL + emailEncoded + urlEnd | ||
|
|
||
| fetch(url, { method: 'POST' }) |
Contributor
There was a problem hiding this comment.
I think we should improve error handling.
For fetch(), 4xx and 5xx responses are not errors. They represent an error on the part of the API, but they don't trigger the .catch() (98). This means that if there is any error in zapier, or one of the services it uses, and fetch() returns 500, the user will get a success message, when in fact the email won't be registered to the subscription list.
| return | ||
| } | ||
|
|
||
| const isValid = await checkEmail(email) |
Contributor
There was a problem hiding this comment.
The error treatment here is innacurate. checkEmail(email) can return false for reasons other than invalid emails:
- The RapidAPI request fails.
- The RapidAPI response is otherwise unusable.
- NEXT_PUBLIC_NEWSLETTER_API_KEY is missing - (E.g., I tested the component with storybook and entered my VTEX email. I got the 'invalid email' error message and this was probably the reason.) This is probably not an issue in production once the environment is correctly configured.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
To test locally:
yarn install.feat/subscription-list:git checkout feat/subscription-list.yarn storybook.http://localhost:6006/and navigate to SubscriptionList in the left sidebar.Types of changes