React Express中的POST方法

我需要做的是:点击buttonadd用户后,我想诱导POST方法到数据库MySQL。 我必须从另一个文件连接到数据库比server.js,但我得到错误

 Net.createConnection is not a function 

这是我的Compontent文件

 import React, { PropTypes} from 'react'; import { connect } from 'react-redux'; import { CounterActions } from '../redux/actions'; import { Link } from 'react-router' import mysql from 'mysql' var connection = mysql.createConnection({ host : 'xxx', user : 'xxx', password : 'xxx', database : 'xxx' }); connection.connect(function(error){ if(!!error){ console.log('error'); }else{ console.log('Connected to db'); } }) class App extends React.Component{ constructor(props){ super(props); } click(){ this.props.testClick(); } render(){ return ( <div> <h1>Hallow Reduxasd <div></div></h1> <h2>Counter: {this.props.global.counter}</h2> <button onClick={this.click.bind(this)}>Click Me!</button> <Link to="/test">Test</Link> <h3><Link to={'/user/'+this.props.global.counter}>{'Link do user id: '+this.props.global.counter}</Link></h3> </div> ) } }