Async and Await produce null response

I can’t figure out why when I sent a test request with Postman I get null as “resp” with the following code:'/api/login', async (req, res) => {
    const {email, password} = req.body
    console.log(email, password);

    const resp = await User.findOne({password})


    if(!resp) {
        console.log("incorrect details")

    } else {
        console.log("logging you in")


However, if I remove them, it works as expected. Can anyone explain why? It might be because I’m new to async/await.

Try searching for the user by email.

1 Like

Well, I just tried and it’s the same behavior, but I added a new user to the database and it finds that one so I guess the problem isn’t with async and await like I thought