【发布时间】:2015-10-27 14:33:14
【问题描述】:
我想问一下是否有人在 JSON 格式上得到相同的响应:
Objectdata:“用户未授权”标题:(名称){status:403statusText:“Forbidden”
场景:
用户 A 发布产品并对该产品添加评论。 结果:成功。
用户 B 对同一产品的评论: 结果:用户未被授权。
我用来更新产品评论的代码在这里: 应用程序名称/`
// Add comment to Product
$scope.comment = function(){
// console.log("name: ",$scope.user);
// console.log("textarea: ",this.commentarea);
var comment = {
name: $scope.product.user.displayName,
text: this.commentarea
};
$scope.product.comments.push(comment);
$scope.product.$update(function() {
console.log('success update');
}, function(errorResponse) {
console.log('success error', errorResponse);
});
};
这是服务器端。
'use strict';
/**
* Module dependencies.
*/
var init = require('./config/init')(),
config = require('./config/config'),
mongoose = require('mongoose'),
chalk = require('chalk');
/**
* Main application entry file.
* Please note that the order of loading is important.
*/
// Bootstrap db connection
var db = mongoose.connect(config.db, function(err) {
if (err) {
console.error(chalk.red('Could not connect to MongoDB!'));
console.log(chalk.red(err));
}
});
// Init the express application
var app = require('./config/express')(db);
// Bootstrap passport config
require('./config/passport')();
// Start the app by listening on <port>
app.listen(config.port);
// Expose app
exports = module.exports = app;
// Logging initialization
console.log('MEAN.JS application started on port ' + config.port);
【问题讨论】:
标签: angularjs mongodb mongoose meanjs