Advertisement
Guest User

Untitled

a guest
Nov 4th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. import React from 'react';
  2. var mysql = require('mysql');
  3. var connection = mysql.createConnection({
  4. host : 'localhost',
  5. user : 'root',
  6. password: '',
  7. database: 'pep'
  8. });
  9.  
  10. connection.connect();
  11. var Menu=React.createClass({
  12. data : function (){
  13. connection.query('Select * from '+this.props.table, function(err, rows, fields){
  14. if(err) throw err;
  15. console.log(rows);
  16. })
  17. },
  18. render : function () {
  19. return (
  20. <div>
  21. <button onClick={this.data}>click</button>
  22. </div>
  23. );
  24. }
  25. });
  26. export default Menu;
  27.  
  28. Connection.js:91 Uncaught TypeError: Net.createConnection is not a function
  29. at Connection.connect (webpack:///./~/mysql/lib/Connection.js?:91:13)
  30. at eval (webpack:///./src/Menu.js?:24:12)
  31. at Object.<anonymous> (http://localhost:3000/static/js/bundle.js:2983:2)
  32. at __webpack_require__ (http://localhost:3000/static/js/bundle.js:556:30)
  33. at fn (http://localhost:3000/static/js/bundle.js:87:20)
  34. at eval (webpack:///./src/Combobox.js?:18:13)
  35. at Object.<anonymous> (http://localhost:3000/static/js/bundle.js:3121:2)
  36. at __webpack_require__ (http://localhost:3000/static/js/bundle.js:556:30)
  37. at fn (http://localhost:3000/static/js/bundle.js:87:20)
  38. at eval (webpack:///./src/App.js?:18:17)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement