【发布时间】:2015-10-26 14:02:08
【问题描述】:
我在我的项目中使用node-restful,我想用moment 替换我的日期属性。
当我像下面这样尝试时;
var QuestionResource = app.user = restful.model('Question', questionSchema)
.methods(['get', 'post', 'put', 'delete']);
QuestionResource
.after('get', function(req, res, next) {
res.locals.bundle.forEach(function(question) {
res.locals.bundle[res.locals.bundle.indexOf(question)].created_at = moment(question.created_at).fromNow()
})
next()
})
响应数据未更改。为什么?怎么会这样?
提前致谢。
【问题讨论】:
标签: javascript node.js express momentjs