現在裝parser,session 要換下方式:
var cookieParser=require('cookie-parser');
var cookieSession=require('cookie-session');
app.use(cookieParser());
app.use(cookieSession({
secret:'imooc'
}))
var cookieParser=require('cookie-parser');
var cookieSession=require('cookie-session');
app.use(cookieParser());
app.use(cookieSession({
secret:'imooc'
}))
2017-12-27
github上面記錄了碰到的imooc的學習問題和最后的解決,基本有中文的注釋,可以參考。
https://github.com/yifon/nodejs-learning
https://github.com/yifon/nodejs-learning
2017-12-27
req.param()已被棄用
http://www.expressjs.com.cn/4x/api.html#req.param
http://www.expressjs.com.cn/4x/api.html#req.param
2017-12-26
老師comment.reply.push(reply)后save保存入數據庫出現報錯MongoError: Unknown modifier: $pushAll是什么原因導致的
2017-12-25
(上一條評論寫不下了,這里繼續)
我的項目是前后端分離 vue + axios + element-ui + express(4.15) 除了express更新問題可能比其他同學遇到了不少坑,比如前端cookie默認不發送(ajax自動發送),跨域問題的解決等
服務端地址:https://github.com/IssacSix/ddblogServer
前端:https://github.com/IssacSix/ddblog
我的項目是前后端分離 vue + axios + element-ui + express(4.15) 除了express更新問題可能比其他同學遇到了不少坑,比如前端cookie默認不發送(ajax自動發送),跨域問題的解決等
服務端地址:https://github.com/IssacSix/ddblogServer
前端:https://github.com/IssacSix/ddblog
2017-12-10
不能通過app以傳參方式注冊路由,需要用express.Router()注冊中間件,否則會報錯,如下: throw new TypeError('Router.use() requires middleware function but got a ' + gettype(fn))
1.app.use('/', webRoutes) // app.js 中注冊中間件 (webRoutes:路由配置文件)
2.var router = express.Router()
3.router.post(url, fun) // webRoutes中設置路由的回調函數
1.app.use('/', webRoutes) // app.js 中注冊中間件 (webRoutes:路由配置文件)
2.var router = express.Router()
3.router.post(url, fun) // webRoutes中設置路由的回調函數
2017-12-10
這段代碼comment.reply.push(newReply),報錯:TypeError:Cannot read property 'push' of undefined
可能是數據模型沒有聲明對,記得是一個數組 才能調自身的.push方法 注意方括號[ { ... } ]
reply : [{
from : { type: ObjectId, ref : "User"},
to : { type :ObjectId, ref : "User" },
content : String
}],
可能是數據模型沒有聲明對,記得是一個數組 才能調自身的.push方法 注意方括號[ { ... } ]
reply : [{
from : { type: ObjectId, ref : "User"},
to : { type :ObjectId, ref : "User" },
content : String
}],
2017-12-01