Meteor使用本地连接导致错误:insert failed:404 - 找不到方法 [英] Meteor using a local connection results in error: insert failed: 404 -- Method not found

查看:153
本文介绍了Meteor使用本地连接导致错误:insert failed:404 - 找不到方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在客户端有一个流星集合

I've got a meteor collection on the client side

Friends = new Meteor.Collection("Friends");
Meteor.subscribe("Friends");

我有一个用户通过facebook验证,我想获取他们的朋友列表:

I have a user authenticate with facebook and I want to grab a list of their friends:

FB.api("/me/friends?    auth_token="+response.authResponse.accessToken,
    function(response){
        for (i = 0; i<response.data.length;i++){
            Friends.insert(response.data[i]);
    }
);

我有一个函数来获取该列表:

I have a function to get that list:

Template.Friends.all_friends = function(){
    return Friends.find();
} 



我有一个模板,希望在屏幕上显示所有的朋友:

I have a template that would like to display all the friends on the screen:

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

页面上似乎发生的是所有的朋友

What appears to be happening on the page is that all the friends DO flash up on the screen for a split second then immediately the screen flashes back to blank.

在javascript控制台中,每个朋友都会显示一次消息(是的,它是多于零,感谢问)

In the javascript console the message appears once per friend I have (yes, it is more than zero, thanks for asking)

insert failed: 404 -- Method not found

那么!我错过了什么?

So! What have I missed? Anyone?

推荐答案

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

You need that Collection declaration on both the client and the server.

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

这篇关于Meteor使用本地连接导致错误:insert failed:404 - 找不到方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆