我在客户端有一个流星集合
Friends = new Meteor.Collection("Friends");
Meteor.subscribe("Friends");
Run Code Online (Sandbox Code Playgroud)
我有一个用户通过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]);
}
);
Run Code Online (Sandbox Code Playgroud)
我有一个函数来获取该列表:
Template.Friends.all_friends = function(){
return Friends.find();
}
Run Code Online (Sandbox Code Playgroud)
我有一个模板,希望在屏幕上显示所有朋友:
<template name="Friends">
{{#each all_friends}}
<div id="{{id}}" class="friend">
<img src="http://graph.facebook.com/{{id}}/picture" />
{{name}}
</div>
{{/each}}
</template>
Run Code Online (Sandbox Code Playgroud)
这似乎是在页面上发生的事情是,所有的朋友DO闪烁在屏幕上的一瞬间,然后立即在屏幕上闪烁回空白.
在javascript控制台中,每个朋友都会显示一条消息(是的,它大于零,感谢您的询问)
insert failed: 404 -- Method not found
Run Code Online (Sandbox Code Playgroud)
所以!我错过了什么?任何人?
我的 Meteor 的 JS 文件有问题。当我尝试将任何数据插入数据库并反映在图表上时,我收到此错误“插入失败:找不到方法”。我试过直接从数据库中获取数据,但这些数据也不起作用......提前谢谢。
LinePeople = new Mongo.Collection("LinePeople");
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
if (Meteor.isClient) {
console.log("in LIne Client");
//LinePeople = new Mongo.Collection(null);
Template.linenvd3.rendered = function() {
var chart = nv.models.lineChart()
.margin({left: 80}) //Adjust chart margins to give the x-axis some breathing room.
.useInteractiveGuideline(true) //We want nice looking tooltips and a guideline!
.transitionDuration(350) //how fast do you want the lines to transition?
.showLegend(true) //Show the legend, allowing users to …Run Code Online (Sandbox Code Playgroud)