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

What is asyncHandler? #26239

Closed
danbraun opened this issue Apr 16, 2023 · 3 comments
Closed

What is asyncHandler? #26239

danbraun opened this issue Apr 16, 2023 · 3 comments
Assignees
Labels
Content:Learn:Express Learning area Express docs

Comments

@danbraun
Copy link

MDN URL

https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/Displaying_data/BookInstance_list_page

What specific section or headline is this issue about?

bookinstanceController code

What information was incorrect, unhelpful, or incomplete?

asyncHandler does not exist.

What did you expect to see?

The method shouldn't be wrapped in this function which is not defined.

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@danbraun danbraun added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Apr 16, 2023
@hamishwillee hamishwillee added Content:Learn:Express Learning area Express docs and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Apr 16, 2023
@hamishwillee hamishwillee self-assigned this Apr 16, 2023
@hamishwillee
Copy link
Collaborator

hamishwillee commented Apr 17, 2023

Hi @danbraun

The handler is set up when you set your routes in an earlier part of the tutorial: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/routes#bookinstance_controller

The purpose of the handler is covered in the earlier section https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/routes#handling_exceptions_in_route_functions. Note you should read the section before this too - they "tell a story in order".

The handler is then described again in the first tutorial for setting up a page: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/Displaying_data/Home_page#controller
I haven't duplicated this explanation in every part of the tutorial, because it would be boring, and should not be necessary.

You may have missed this because you did the routes and earlier parts of the tutorial last week and then took a few days break. The documentation was just updated late last week so you would have missed this information. If so, many apologies.

I'm, going to close as "not a defect", but if I'm missing something feel free to reopen.

@danbraun
Copy link
Author

danbraun commented Apr 17, 2023 via email

@hamishwillee
Copy link
Collaborator

Great. Sorry you got caught in the docs update. I had to add this because mongoose no longer supports a callback API - only promises. The tutorial is much better for moving to await/async though, because you no longer have to include boilerplate for the error handling in every function. Good luck with the tutorial, and thanks for taking the time to raise issues.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Content:Learn:Express Learning area Express docs
Projects
None yet
Development

No branches or pull requests

2 participants