-
-
Notifications
You must be signed in to change notification settings - Fork 16.4k
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
Possible to return a response in Express 5? #3884
Comments
Hi! We are still working on docs and such, so don't have anything to point to yet.
At least, not like in your example. The API for sending responses is the same as Express 4. Middleware and handlers can now return promises and if the promise is rejected, next(err) will be called with err being the value of the rejection. The resolved value of the promise is ignored. |
Thanks Doug! I took Promises as 'removing callbacks' and instead it's allowing Promises in more places. I appreciate the response (even if it wasn't the answer I wanted) - have a good one. |
I think this issue can be closed :) |
To clarify, the answer is no you cant send a response by returning an object from a route handler. This is a pattern that’s used in Lambda functions, for example. You can write a helper function and wrap your route handler in it that would send a response based on the object returned, but Express’s method for sending responses is not changing in v5. |
I've read #2259 there a single example of a route using Promises? I've read the router changelogs etc, from alpha 2 to alpha 7, but I can't find anything.
I know, eg, https://arc.codes lets me just return a response. It also has middleware that uses this pattern.
Does express 5 allow me to return a response from a route?
The text was updated successfully, but these errors were encountered: