var express = require('express');
var bodyParser = require('body-parser')
var port = process.env.PORT || 3000
var app = express()
var path = require('path');
var mongoose = require('mongoose')
var _ = require('underscore')
var fs = require('fs');
var jsonParser = bodyParser.json()
var urlencodedParser = bodyParser.urlencoded({ extended: false })
mongoose.connect('mongodb://localhost/meetdb')
app.set('views', './views/pages')
app.set('view engine', 'jade')
app.use(urlencodedParser);
app.use(express.static(path.join(__dirname, 'public')))
app.listen(port)
// user 相关
app.post('/user/signup',function (req,res){
console.log(req.params)
console.log(req.body)
})
可以获取到req.body,但是无法获取到req.params。我看网上说的是可以同时获取query和body的值。
通常是req.params吧,来获取路径中的参数