I'm trying to connect to mongodb in my react app but it throws error:
Unable to get property 'replace' of undefined or null reference
the error occurs when I console.log(err) in the callback of the connect method
import React from 'react';
import {MongoClient} from "mongodb";
function App(){
// user, pass, cluster, and db are replaced in my actual code
const uri = "mongodb+srv://<user>:<pass>@<cluster>.mongodb.net/<db>?retryWrites=true&w=majority";
MongoClient.connect(uri, {useNewUrlParser: true}, (err, db) => {
if (err) console.log(err.message);
}
return (
// html markup
);
}
export default App;
I am unfamiliar with this error as I have never accoutered this before