IsConnected not a function in next.js app

This is how I’m calling my api routes:

import clientPromise from "../../../lib/mongodb";
export default async (req, res) => {
    const client = await clientPromise
    const { fieldvalue } = req.query
    const database = client.db('databasename');
    const userdb = await database.collection('collectionname')
      .find({ "<field>": `${ fieldvalue }` })
      .project({ "_id": 0 })
      .toArray();
  res.json(userdb)
}
2 Likes