1
저는 서버에 양식을 구문 분석하기 위해 Express.js 및 body-parser
모듈을 사용했습니다. 그러나 콘텐츠가 수신되면 res.body
은 빈 개체로 표시됩니다.Express 폼 구문 분석이 작동하지 않습니다.
app.js : (옥)
var express = require("express");
var app = express();
var bp = require("body-parser");
app.set('views', __dirname + '/views');
app.use(bp.json());
app.use(express.static(__dirname + '/public'));
app.get('/', function (req, res) {
res.render('index.jade');
});
app.post('/', function (req, res) {
console.log(req.body);
});
app.listen(process.env.PORT || 5000);
형태 :
form(method="post", action="/", enctype="application/json")
input(type="text", name="name", placeholder="input your name")
왜 그렇게이며 어떻게 고정 할 수있다?
감사합니다. 시간 제한을 기다리는 중 ... – kyr