How to send an object that I read from MongoDB to node js to another js file?
I want to send arr to another js file.
MongoClient.connect(connectionURL, { useNewUrlParser: true }, (error,
client) => {
if (error) {
return console.log("Can't connect to db");
}
const db = client.db(databaseName); jasonArray0 = [
{
opentime: 2000,
image: "cat.jpg"
}
];
db.collection('stam').insertMany(jasonArray0, (error, result) => {
if (error) {
return console.log('Could not insert')
}
console.log(result.ops)
})
db.collection('stam').findOne({
_id: new mongodb.ObjectID("61ca52a727dc9d8f089d04d6")
}, (error, task) => {
arr.push(task.image)
}) })