title: How to connect MySQL database to ReactJS app?
body: <p>I have build a Todo App with create-react-app. The store I'm using is based on Local Storage(JS attribute of object window). Now I created a MySQL databases and want to connect to that database, so the state will show the values from database, and will be updated through actions. </p>
  
  <p>I've tried to connect to db and output values through 'node' console using db.js. It works.</p>
  
  <pre><code>const mysql = require('mysql');
  
  const con = mysql.createConnection({
    host: "localhost",
    user: "root",
    password: "root",
    database: 'root'
  });
  
  con.connect(function(err) {
    if (err) throw err;
    con.query("SELECT * FROM tasks", function (err, result, fields) {
      if (err) throw err;
      console.log(result);
    });
  });
  </code></pre>
  
  <p>Is it possible to connect the state of app to database using this script?</p>