I'm writing a chrome extension that needs to access the data from my MongoDB database and store it locally. I've searched around for guides but all of them are Node.js, but I need a solution in native javascript. Security isn't an issue since the data in the database isn't private.
I get an error immediatly when I try to connect to the database (first line).
mongodb.MongoClient.connect('mongodb+srv://<NAME>:<PASSWORD>@<NAME>.a1bc2.mongodb.net/<NAME>?retryWrites=true&w=majority', function(err, db) {
if (err) throw err;
var dbo = db.db("PlayerPrices");
dbo.collection("Playstation").find({}).toArray(function(err, result) {
if (err) throw err;
let fullRecord = JSON.parse(result);
console.log(fullRecord);
chrome.storage.local.set({ 'playstationRecord': fullRecord }, function() {
console.log('playstation Data Received');
});
db.close();
});
});