node+express POST请求
// POST 登录 app.post('/login', function (req, res) { // 定义了一个post变量,用于暂存请求体的信息 let [post,addSql,addSqlParams] = ['','',[]] // 通过req的data:数据加载,事件监听函数,每当接受到请求体的数据,就累加到post变量中 req.on('data', function(chunk){ post += chunk; let obj = eval('(' + post.toString() + ')'); console.log(post) let [name,password] = [obj.name,obj.password]; addSql = 'SELECT id FROM user WHERE name=? and password=?'; addSqlParams = [name,password] post = obj; });