Collections Meteor使用本地连接导致错误:插入失败:404--找不到方法
我有一个流星收集在客户端Collections Meteor使用本地连接导致错误:插入失败:404--找不到方法,collections,client-side,meteor,Collections,Client Side,Meteor,我有一个流星收集在客户端 Friends = new Meteor.Collection("Friends"); Meteor.subscribe("Friends"); 我有一个用户通过facebook验证,我想获取他们朋友的列表: FB.api("/me/friends? auth_token="+response.authResponse.accessToken, function(response){ for (i = 0; i<response.d
Friends = new Meteor.Collection("Friends");
Meteor.subscribe("Friends");
我有一个用户通过facebook验证,我想获取他们朋友的列表:
FB.api("/me/friends? auth_token="+response.authResponse.accessToken,
function(response){
for (i = 0; i<response.data.length;i++){
Friends.insert(response.data[i]);
}
);
我有一个模板,希望在屏幕上显示所有好友:
<template name="Friends">
{{#each all_friends}}
<div id="{{id}}" class="friend">
<img src="http://graph.facebook.com/{{id}}/picture" />
{{name}}
</div>
{{/each}}
</template>
所以!我错过了什么?有人吗?您需要在客户端和服务器上同时声明该集合
// common code, do not put under /client or inside Meteor.is_client test
Friends = new Meteor.Collection("Friends");
如果您只想在客户端使用集合,而不需要将该数据保存到服务器,则可以在“客户端”文件夹或.isClient()函数中声明集合,方法是向构造函数传递null,如下所示:
if(Meteor.isClient()){
// Some other code
...
onlyClientCollection = new Meteor.Collection(null);
// Some other code
...
}
这件事让我很烦恼。谢谢你的回答
// common code, do not put under /client or inside Meteor.is_client test
Friends = new Meteor.Collection("Friends");
if(Meteor.isClient()){
// Some other code
...
onlyClientCollection = new Meteor.Collection(null);
// Some other code
...
}