Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- var mysql = require('mysql');
- var connection = mysql.createConnection({
- host : 'localhost',
- user : 'root',
- password: '',
- database: 'pep'
- });
- connection.connect();
- var Menu=React.createClass({
- data : function (){
- connection.query('Select * from '+this.props.table, function(err, rows, fields){
- if(err) throw err;
- console.log(rows);
- })
- },
- render : function () {
- return (
- <div>
- <button onClick={this.data}>click</button>
- </div>
- );
- }
- });
- export default Menu;
- Connection.js:91 Uncaught TypeError: Net.createConnection is not a function
- at Connection.connect (webpack:///./~/mysql/lib/Connection.js?:91:13)
- at eval (webpack:///./src/Menu.js?:24:12)
- at Object.<anonymous> (http://localhost:3000/static/js/bundle.js:2983:2)
- at __webpack_require__ (http://localhost:3000/static/js/bundle.js:556:30)
- at fn (http://localhost:3000/static/js/bundle.js:87:20)
- at eval (webpack:///./src/Combobox.js?:18:13)
- at Object.<anonymous> (http://localhost:3000/static/js/bundle.js:3121:2)
- at __webpack_require__ (http://localhost:3000/static/js/bundle.js:556:30)
- at fn (http://localhost:3000/static/js/bundle.js:87:20)
- at eval (webpack:///./src/App.js?:18:17)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement