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

Expected to return a value at the end of async arrow function consistent-return #140

Closed
niamao opened this issue Dec 16, 2020 · 1 comment

Comments

@niamao
Copy link

niamao commented Dec 16, 2020

Why do I get this error? Can someone please help me?

"Expected to return a value at the end of async arrow function consistent-return."

I use it on an onChange since I would like the URL put in the input to be used.

const handleChange = async (event) => {
try {
const article = await extract(event.target.value)
return article
} catch (err) {
console.trace(err)
}
}

@ndaidong
Copy link
Collaborator

@niamao it seems your handler only returns value in the case everything work well, and returns nothing when there is error occurs.
Try this:

const handleChange = async (event) => {
  try {
    const article = await extract(event.target.value)
    return article
  } catch (err) {
    console.trace(err)
  }
  return null;
}

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

No branches or pull requests

2 participants