接收前端的数据
- var express = require("express");
- var bodyParser = require("body-parser");
- var app = express();
- // need it...
- app.use(bodyParser.urlencoded({ extended: false }));
- app.post('/login/:id',function(req,res){ //注意请求方式
- var password=req.body.password; //post
- var name = req.query.name; //get
- var id=req.params.id //解析路径的 千万不要混淆
- console.log("User name = "+user_name+", password is "+password);
- res.end("yes");
- });