Love Calculator

БЕЗКОШТОВНО
(Ким) Ajith Joseph | Оновлено a month ago | Entertainment
Популярність

9.7 / 10

Затримки

458ms

Рівень обслуговування

97%

Health Check

N/A

Повернутися до всіх обговорень

AngularJS $http & $resource

Rapid account: Morticai
morticai
vor 9 Jahren

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 vor 9 Jahren

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 vor 9 Jahren

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>

Приєднуйтесь до обговорення — додайте повідомлення нижче:

Вхід / Реєстрація, щоб публікувати нові повідомлення