2012-05-07 16 views
8

我有一颗流星收集客户端上的流星使用错误本地连接的结果:插入失败:404 - 未找到方法

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.Friends.all_friends = function(){ 
    return Friends.find(); 
} 

我有一个模板是想显示屏幕上所有的朋友:

<template name="Friends"> 
    {{#each all_friends}} 
    <div id="{{id}}" class="friend"> 
     <img src="http://graph.facebook.com/{{id}}/picture" /> 
     {{name}} 
    </div> 
    {{/each}} 
</template> 

似乎是在页面上发生的事情是,所有的朋友DO闪光灯在屏幕上的一瞬间,然后立即在屏幕上闪烁回到空白。

在每次出现的朋友,我有一次消息JavaScript控制台(是的,它是大于零,询问感谢)

insert failed: 404 -- Method not found 

所以!我错过了什么?任何人?

回答

27

您需要客户端和服务器上的Collection声明。

// common code, do not put under /client or inside Meteor.is_client test 
Friends = new Meteor.Collection("Friends"); 
4

如果你想只在客户端使用的收集和你不需要的数据保存到服务器,你可以在“客户端”文件夹或.isClient()函数声明你的收藏通过传递空到构造如下:

if(Meteor.isClient()){ 
// Some other code 
... 

onlyClientCollection = new Meteor.Collection(null); 

// Some other code 
... 
} 
+0

这件事让我感到困扰。感谢你的回答 – Pawan

相关问题