Thank you, yes I saw all of that, but even with the code below I’m getting the error.
export async function addRecord(db_name,collection_name,record) {
const MongoClient = require('mongodb').MongoClient;
const uri = "mongodb+srv://...";
const client = MongoClient(uri, {useNewUrlParser: true, useUnifiedTopology: true});
await client.connect(err => {
const collection = client.db(db_name).collection(collection_name);
let doc = record;
collection.insertOne(doc, async function (error, response) {
let data = await response.ops[0];
console.log(data)
});
client.close();
});
}
Unsure what I’m missing here.