Using MongoDB to show data online

Hi there. I am currently using MongoDB atlas for my database on my react application and when I run a command to activate the database for local use it will return the info that’s on it. But with my application and deploying it online using AWS amplify to a domain the info won’t show for anyone else on my website. A friend recommended using realm but want to be sure this is the right step. Thanks for any help

Hello @Jack_Haugh, welcome to the MongoDB Community forum!

The react application should retrieve the data even when hosted on the AWS Amplify - as it is doing so from the application on the local machine. It is the configuration and setups that you may want to make sure are complete - likely from the instructions provided by the hosting provider.

I see you are connecting to MongoDB database on Atlas.

A friend recommended using realm but want to be sure this is the right step.

I don’'t know if you should use Realm or not - is it part of your application and its design?

Hi there @Prasad_Saya. Thanks for the reply. I may have said it wrong. What I’m trying to achieve is that a user of any sort comes to our website and they can see the info that should be outputted on the page but it doesn’t show globally and I’m unsure on what. I will send code into here soon to help with he case. If you want to see my problem then the link to the page is https://www.student-mania.com/forumPage . If you see the query page that’s were you type the info and then it sends to the forum page.

Server file

Hello @Jack_Haugh, I see some code you have posted. Please format the code properly - see Formatting code and log snippets in posts. And, which part of the code you had posted is not working as you wanted?

@Prasad_Saya i just put a hyperlink to the server file for review

Hello @Jack_Haugh,

Tell me what are these code snippets doing? You are connecting to MongoDB NodeJS driver and closing the connection. Then the Mongoose#connect - is it connecting?

const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true });

client.connect(err => {
      const collection = client.db("test").collection("devices");
      // perform actions on the collection object
      client.close();
    });

// admin:studentmania      modulesDB
// Connecting to the MongoDB
mongoose.connect(mongoDB,{useNewUrlParser:true});

Hi again.
The server code was giving to us by a lecturer before and it worked locally by running a command called node server.js that ran the server file and took info from our server on MongoDB. Right now if i ran this command it will show the info locally no problem but if i searched the website and looked at forum page on my phone it wont show and thats where im trying to get it to run globally for use by everyone

@Jack_Haugh, Id like to know where is this field coming from: mongoDB. This is meant to be the connection URI to the database.

// Connecting to the MongoDB
mongoose.connect( mongoDB, { useNewUrlParser:true } );

I’m unsure buddy on what you mean. To be honest this was giving to us a year or two ago and never questioned it