I get err MongoInvalidArgumentError: Collection name must be a String
First function:
export default function Questions ({data})
{const [collection, setCollection] = useState("")
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 }, };}
Top comments (0)