DEV Community

ivkeMilioner
ivkeMilioner

Posted on • Edited on

5 4

I get err MongoInvalidArgumentError: Collection name must be a String

I get err MongoInvalidArgumentError: Collection name must be a String

First function:

export default function Questions ({data})
 {const [collection, setCollection] = useState("")
Enter fullscreen mode Exit fullscreen mode

Second function:

export async function getServerSideProps({collection} ) 
{const client = await clientPromise;const db = client.db("javascript_questions");

let data = await db.collection(collection).find({}).toArray();
data = JSON.parse(JSON.stringify(data));
return {props: { data },  };}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more