here's how you can do it:
- Use
process.env.MONGODB_URIfor the connection string. - Call
find({}).toArray()to get all documents and return as JSON.
asked 386 days ago
1
57
I’m new to Next.js API routes and MongoDB—what’s the minimal setup to connect, query one collection, and return JSON?
here's how you can do it:
process.env.MONGODB_URI for the connection string.find({}).toArray() to get all documents and return as JSON.1