Love Calculator

免费
通过 Ajith Joseph | 已更新 एक महीने पहले | Entertainment
人气

9.7 / 10

延迟

490ms

服务等级

97%

Health Check

N/A

返回所有讨论

AngularJS $http & $resource

Rapid account: Morticai
morticai
9 वर्ष पहले

Hello, I’m trying to use your API.

However I’m getting the error:

XMLHttpRequest cannot load https://love-calculator.p.mashape.com/getPercentage. The request was redirected to ‘https://love-calculator.p.mashape.com/user/errorpage?aspxerrorpath=/mashape/lovetest.aspx/getPercentage’, which is disallowed for cross-origin requests that require preflight.

Even though I’m changing the headers to application/json it still appears to be sending back the data as xml.

Any help would be great thanks!

Rapid account: Ajith
ajith Commented 9 वर्ष पहले

Hi,

Something is technically wrong. Thanks for noticing — we’re going to fix it up and have things back to normal soon.

Thanks and regards

Ajith

Rapid account: Morticai
morticai Commented 9 वर्ष पहले

Ended up figuring out the issue.

Here is the code if anyone else is trying to use this API with Angular JS $http warpper.

<pre><code>
var req = {
method: ‘GET’,
url: ‘https://love-calculator.p.mashape.com/getPercentage?fname=nameone&sname=nametwo’,
dataType: ‘json’,
headers: {
‘Accept’: ‘application/json’,
‘X-Mashape-Key’: ‘YOU-API-KEY’
},
};

$http(req).success(function(data) {
$scope.data = data;
console.log(data);

});

};
</pre></code>

加入讨论 - 在下面添加评论:

登录/注册以发布新的评论