我想在Meteor中使用auth连接到rest API,但是当我浏览他们的文档时,无法看到连接到rest API的任何内容。我只能看到HTTP请求。所以,我尝试使用它。我需要连接到这个:
URL: http://lpgp-dev.mrkt.it/test/oauth/rest/testview2
key: 'mykey'
secret: 'my secret'
现在我有这行代码:
来自服务器:
Meteor.methods({
getArticles: function () {
check(q, String);
this.unblock();
try {
var result = HTTP.call("GET", "http://lpgp-dev.mrkt.it/test/oauth/rest/testview2",
{params: {key: 's86MopNFA6pwmBXQoEw8k5yBVAVjN8vz', secret: 'cKC2tpXP3ZRQvqAsobCPeK2jB4kjsDos'}});
return result;
} catch (e) {
// Got a network error, time-out or HTTP error in the 400 or 500 range.
return false;
}
}
});
来自我称之为方法的客户:
var getResponse = function(){
Meteor.call('getArticles', function (error, result) {
if (!error) {
var res = JSON.parse(result.content);
/*var _res = _(res.response.docs).toArray();*/
/*Session.set('numCount', res.response.numFound);
Session.set('news', _res);*/
console.log(res);
}else{
console.log(error);
}
});
}
当我运行它时返回此错误:
errorClass: Internal server error [500] of undefined
希望你能帮助我。感谢...