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

Author: jurijus01Created Apr 14, 2024Updated Apr 14, 2024

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.