搜索完毕后,我累了 任何人都可以告诉我为什么post方法不工作当我在postman.Note中添加Content-Type:multipart / form-data而不添加这个suck一切正常。这是我的app.js
var app = express();
var apiRoutes = require('./routes/apiRoutes');
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(logger('dev'));
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded([{extended: false}, {limit: '50mb'}]));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'uploads')));
app.use(multipart());;
app.use(apiRoutes)
这是我的apiRoutes.js
var express = require('express');
var router = express.Router();
var fn = require('../webservices');
var multipart = require('connect-multiparty')();
router.post('/api/login', fn.test);
module.exports = router;
这是我的webservices.js
function test(req,res){
console.log("hello there");
}
module.exports = {
test
}
并显示错误
TypeError:此[(“visit”+ node.type)]不是函数
请将此整个错误和堆栈跟踪报告给https://github.com/jadejs/jade/issues at Object.visitNode(/home/ais/Acruss-NodeJs/node_modules/jade/lib/compiler.js:225:37) at Object.visit(/home/ais/Acruss-NodeJs/node_modules/jade/lib/compiler.js:212:10) at Object.visitBlock(/home/ais/Acruss-NodeJs/node_modules/jade/lib/compiler.js:295:12) at Object.visitNode(/home/ais/Acruss-NodeJs/node_modules/jade/lib/compiler.js:225:37) at Object.visit(/home/ais/Acruss-NodeJs/node_modules/jade/lib/compiler.js:212:10) at Object.compile(/home/ais/Acruss-NodeJs/node_modules/jade/lib/compiler.js:66:10) 在解析(/home/ais/Acruss-NodeJs/node_modules/jade/lib/index.js:114:19) at Object.exports.compile(/home/ais/Acruss-NodeJs/node_modules/jade/lib/index.js:205:16) 在handleTemplateCache(/home/ais/Acruss-NodeJs/node_modules/jade/lib/index.js:174:25) at Object.exports.renderFile(/home/ais/Acruss-NodeJs/node_modules/jade/lib/index.js:380:10)