title: How to get data from back end side, to use it in the browser side?
body: <p>I am new to programming, and I heard that some guys on this website are quite angry, but please don't be. I am creating one web app, that has a web page and also makes som ecalculations and works with database (NeDB). I have an index.js </p>
  
  <pre><code>    const selects = document.getElementsByClassName("sel");
      const arr = ["Yura", "Nairi", "Mher", "Hayko"];
      for (let el in selects) {
        for (let key in arr) {
          selects[el].innerHTML += `&lt;option&gt;${arr[key]}&lt;/option&gt;`;
        }
      }
  </code></pre>
  
  <p>I have a function which fills the select elements with data from an array.</p>
  
  <p>In other file named: getData.js: </p>
  
  <pre><code>    var Datastore = require("nedb");
      var users = new Datastore({ filename: "players" });
      users.loadDatabase();
  
      const names = [];
  
      users.find({}, function (err, doc) {
         for (let key in doc) {
            names.push(doc[key].name);
         }
      });
  </code></pre>
  
  <p>I have some code that gets data from db and puts it in array. And I need that data to use in the index.js mentioned above, but the problem is that I don't know how to tranfer the data from getData.js to index.js. I have tried module.exports but it is not working, the browser console says that it can't recognize require keyword, I also can't get data directly in index.js because the browse can't recognize the code related to database. </p>