Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix error in README example #823

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dmitrytarassov
Copy link

@dmitrytarassov dmitrytarassov commented Jan 23, 2025

There is an error in your example in the README. The expression validate().then(console.log("Valid List.")) will log Valid List. to the console regardless of whether the function completes successfully or throws an error. The correct approach is to pass a function to then that will be executed when the promise is resolved, instead of calling the function immediately.

image image
// WRONG
validate()
  .then(console.log("Valid List."))
  .catch(console.error)
// CORRECT
validate()
  .then(() => console.log("Valid List."))
  .catch(console.error)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants