title: Set the result of a query to a variable in MySQL (node js)
body: <p>How i can set result of a COUNT query to variable: 
  I have a function: </p>
  
  <pre><code>exports.someFunction = function (req, res) {
      var user =  req.session.user,
      userId = req.session.session_id;
      if(userId == null){
         res.redirect("/login");
         return;
      }
      let sql = `SELECT COUNT(*) FROM table WHERE id_one = ? AND status = ?`;
      let post = [userId, 2];
      connection.query(sql, post, (err, result) =&gt; {
          if(err){
              console.log(err)
          }
          res.json(result);
          let a = setValue(result);
          console.log(a);
      });
  
  };
  
  function setValue (result) {
      let a = result;
  }
  </code></pre>
  
  <p>When I set result of query to variable <code>a</code> I get undefined. Please help me fix this problem. </p>