title: How to use variable from node server into another javascript file
body: <p>Hello I'm new to node js, and came across using it while making an rtc project where I have to make calls, I use rtcmulticonnection library which has server.js and index.html</p>
  
  <p>In index.html I have some data I want to push into the mysql database, so I use this code in server.js:</p>
  
  <pre><code>const mysql = require('mysql');
  const connectionsql = mysql.createConnection({
  host: 'localhost',
         user: 'root',
         password: '',
         database: 'test'
  });
  connectionsql.connect((err) =&gt; {
      if (err) throw err;
      console.log("Connected!");
  });
  </code></pre>
  
  <p>The above code is for connection to mysql in server.js so now I have some data in index.html (coming different each time).. I want to push into the database, how can i send that to server.js file and make a commit? i cannot use connectionsql into the script tag in index.html(script tag) file so can create a query like this:</p>
  
  <pre><code>const call = { room_id: caller_id, callee_id: callee_id };
  connectionsql.query('INSERT INTO chat_calls SET ?', call, (err, res) =&gt; {
      if(err) throw err;
      console.log('Last insert ID:', res.insertId);
  });
  </code></pre>