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

Res.redirect won't work for async routes at all? #1973

Open
jurijus01 opened this issue Apr 14, 2024 · 0 comments
Open

Res.redirect won't work for async routes at all? #1973

jurijus01 opened this issue Apr 14, 2024 · 0 comments

Comments

@jurijus01
Copy link

Hello Restify!

Don't know whether it's a bug or feature request. My case is as follows:

I have an async route

server.get("/verify", async (req, res) => {}

containing interaction with MongoDB via Mongoose. In that route I need to use res.redirect, which won't work, because, apparently, it needs "next", which is not declared in async routes.

I tried going the ugly "Callback Hell" way and rewriting everything without await/async, but, apparently, Mongoose no longer supports callbacks - for all the good reasons. It gave an error:

MongooseError: Model.findOne() no longer accepts a callback

Please help with an advice how to make res.redirect work in async routes.

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

1 participant