Skip to content

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

@jurijus01

Description

@jurijus01

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions