hi i want to connect my nextjs app with mongoose to mongodb database but when i type await dbconnect() it return an error saying i should set topLevelAwait=true but in nextjs.config file there is not such thing even when i type it myself it return the same error
i tried googling it and i found a stackoverflow question but it was for earlier version of next-js and it dosnt work for next 13
file dbConect
import mongoose from "mongoose";
const dbConnect = async () => {
try {
const { connection } = mongoose.connect(
"mongodb+srv://<username>:<password>@cluster0.slqa5pz.mongodb.net/?retryWrites=true&w=majority"
);
if (connection.readyState == 1) {
console.log("database connected");
}
} catch (error) {
console.log(error);
}
};
export default dbConnect;
file api
import dbConnect from "@/database/dbConnect"
export async function GET(request) {
await dbConnect()
return new Response('Hello, Next.js!')
}