我有以下代码正在获取kubectl version --short
。我该如何解决?
POST is not function error
const express = require('express');
const router = express.Router();
const Post = require('../../models/Post');
router.all('/*',(req, res, next)=>{
req.app.locals.layout='admin';
next();
});
router.get('/',(req, res)=>{
res.send('It Works');
});
router.get('/create',(req, res)=>{
res.render('admin/posts/create');
});`// router.post('/create',(req, res)=>{
// res.send('worked');
// });
router.post('/create', (req, res)=>{
let allowComments=true;
if(req.body.allowComments){
allowComments=true;
}else{
allowComments=false;
}
Post({
title: req.body.title,
status: req.body.status,
allowComments:allowComments,
body: req.body.body
});
newPost.save().then(savedPost=>{
res.redirect('/admin/posts');
}).catch(error=>{
console.log('could not post');
});
// console.log(req.body);
});
module.exports=router;
模型是
Post
答案 0 :(得分:0)
您有-在此处签名
number
这将使您的导入成为const Post = require('../../models/Post');
(实际上是NaN)
const module = {}
function foo(){
}
module.exports = foo
console.log(module)
module.exports = -foo
console.log(module)
数字不是函数。
ID | NAME | Subject
---+------+----------
1 | Mark | English
1 | Mark | Math
2 | Matt | Math
2 | Matt | English
1 | Mark | History