没有什么比在一项简单的任务上失败更令人沮丧的了。
我正在关注:https ://docs.mongodb.com/stitch/getting-started/first-stitch-app/ - 我进入了 setp 9 - 这应该清除权限规则,所以任何人都可以查看我的职位;但是,我仍然收到权限错误。
Uncaught (in promise) Error: no rule exists for namespace 'blog.comments'
at client.js:343
at <anonymous>
这是整个代码 - 但我怀疑错误出在针迹设置方面。是的 - 我已经用我的应用程序 ID 替换了“your-app-id”...我确实清除了过滤器,并且我确实将 READ 权限更改为 {}...
<html>
<head>
<script src="https://s3.amazonaws.com/stitch-sdks/js/library/v2/stable/stitch.min.js"></script>
<script>
const client = new stitch.StitchClient('<your-app-id>');
const db = client.service('mongodb', 'mongodb-atlas').db('blog');
function displayComments() {
db.collection('comments').find({}).execute().then(docs => {
var html = docs.map(c => '<div>' + c.comment + '</div>').join('');
document.getElementById('comments').innerHTML = html;
});
}
function displayCommentsOnLoad() {
client.login().then(displayComments)
}
function addComment() {
var c = document.getElementById('new_comment');
db.collection('comments').insertOne({owner_id : client.authedId(), comment: c.value})
.then(displayComments);
c.value = '';
}
</script>
</head>
<body onload="displayCommentsOnLoad()">
<h3>Aspirational blog post</h3>
<div id="content">
I like to write about technology, because I want to get on the front page of hacker news (in a good way).
</div>
<hr>
<div id="comments"></div>
<hr>
Add comment:
<input id="new_comment"><input type="submit" onClick="addComment()">
</body>
</html>
如果第一个真正的步骤失败了,那就不能再进一步了。任何帮助表示赞赏。