没有什么比失败的简单任务更令人沮丧。
我跟着: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>
这里是整个代码 - 但我怀疑错误是在针脚设置方面。 是的 - 我已经替换了#34;你的app-id&#34;用我的app id ... 我DID清除过滤器,我确实将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>
如果第一个真正的步骤失败,就不能再进一步了。 感谢任何帮助。