试图从流星的vimeo api返回json数据



我试图返回一些json数据从vimeo API在流星和有回调和服务器vs客户端东西的一些麻烦这是我下面的代码,但它不工作,因为它可以看到的http请求是在一个变量在客户端服务器端但如果我把它放在客户端我得到一个阻塞错误

if (Meteor.isServer) {
  var auth_url='http://vimeo.com/api/v2/video/92861889.json';
}
 //invoke the server method
 if (Meteor.isClient) {
   result = Meteor.http.call("GET", auth_url);
    var issue = JSON.parse(result.content);
    console.log(issue);
 }

Update: Current Error

     Uncaught SyntaxError: Unexpected token < test.js?6011fceba7e0032b9fbc7fe1cec33965967603ed:24
(anonymous function) test.js?6011fceba7e0032b9fbc7fe1cec33965967603ed:24
(anonymous function) httpcall_client.js:63
(anonymous function) underscore.js:750
xhr.onreadystatechange
新代码

好的,所以我重新输入了所有的代码,问题是一个看不见的字符从复制和粘贴,从我可以告诉。然而,我得到了一个交叉原点错误,所以我做了更多的研究,发现这是正确的方式来做回调。然而,我得到一个错误"无法读取属性"未定义的"内容"更多的帮助将不胜感激。我为json选择了一个不同的url,只是为了测试的目的。

if (Meteor.isServer) {
  Meteor.startup(function () {
    Meteor.methods({
      'remoteGet' : function(url, options){
        return HTTP.get(url,options);
      }
    });
  });
}
if (Meteor.isClient) {
  Meteor.call('remoteGet', 'http://www.kimonolabs.com/api/ahd8tq6q?apikey=6c55fc2ded8114a1c08b8a914851de84',{
  },function(error,response){
    var issue = JSON.parse(response.content);
    console.log(issue);
});
}

在客户端,异步操作不能以同步方式写入。需要回调:

 if (Meteor.isClient) {
   result = Meteor.http.call("GET", auth_url, function (err, result) {
     var issue = JSON.parse(result.content);
     console.log(issue);
   });
 }

似乎Vimeo更新了这个Json数据提要,所以它必须是:

https://vimeo.com/api/oembed.json?url=https://vimeo.com/{VIMEOID}

最新更新