I am having issues setting up session storage with MongoDB for my app and getting the TypeError described in the title.
After referring to the Read.me and shopify-api-node/src/auth/session/storage at main · Shopify/shopify-api-node (github.com) I configured the Shopify.Context.initialize SESSION_STORAGE for a MongoDB database. I have tried both methods, withCredentials and without. I can see in my GUI for MongoDB there is some connection happening regardless of the error. I have also verified that I can connect to the DB with those same credentials but outside of the Shopify.Auth.Session.MongoDBSessionStorage method.
Has anyone else had this issue? I’m not sure what else to do.
// This should be replaced with your preferred storage strategy
// SESSION_STORAGE: Shopify.Auth.Session.MongoDBSessionStorage.withCredentials(
// "cluster0.xyz123.mongodb.net",
// "DBName",
// "verified_username",
// "verified_password"
// ),
SESSION_STORAGE: new Shopify.Auth.Session.MongoDBSessionStorage(
"mongodb+srv://verified_username:verified_password@cluster0.xyz123.mongodb.net/?retryWrites=true&w=majority",
"DBName"
),
// I also tried a different version of the connecting url that was closer to the documentation: mongodb://verified_username:verified_password@cluster0.xyz123.mongodb.net/
// Verified Connection in the same index.js by use of console.log() and monitoring DB
import { MongoClient, ServerApiVersion } from "mongodb";
const uri =
"mongodb+srv://verified_usernmae:verified_password@cluster0.xyz123.mongodb.net/?retryWrites=true&w=majority";
const client = new MongoClient(uri, {
useNewUrlParser: true,
useUnifiedTopology: true,
serverApi: ServerApiVersion.v1,
});
async function run() {
try {
await client.connect();
// perform actions on the collection object
await client.db("admin").command({ ping: 1 });
console.log("Connected successfully to server");
} finally {
await client.close();
}
}
run().catch(console.dir);