Meteor 使用本地连接导致错误:insert failed: 404 -- Method not found [英] Meteor using a local connection results in error: insert failed: 404 -- Method not found
问题描述
我在客户端有一个流星集合
Friends = new Meteor.Collection("Friends");Meteor.subscribe("朋友");
我有一个用户通过 facebook 进行身份验证,我想获取他们的朋友列表:
FB.api("/me/friends?auth_token="+response.authResponse.accessToken,功能(响应){for (i = 0; i
我有一个函数来获取该列表:
Template.Friends.all_friends = function(){返回 Friends.find();}
我有一个模板,想在屏幕上显示所有朋友:
{{#each all_friends}}<div id="{{id}}" class="friend"><img src="http://graph.facebook.com/{{id}}/picture"/>{{名称}}
{{/每个}}模板>
页面上似乎发生的事情是所有朋友DO在屏幕上闪了一下,然后屏幕立即闪回空白.
在 javascript 控制台中,消息为我的每个朋友显示一次(是的,它多于零,感谢提问)
insert failed: 404 -- 方法未找到
所以!我错过了什么?有人吗?
您需要在客户端和服务器上都使用 Collection 声明.
//常用代码,不要放在/client下或Meteor.is_client里面测试Friends = new Meteor.Collection("Friends");
I've got a meteor collection on the client side
Friends = new Meteor.Collection("Friends");
Meteor.subscribe("Friends");
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.
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?
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 -- Method not found的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!