Ich habe diesen API-Aufruf in Postman Arbeit zu tun, aber wenn ich den Code in meinen JS-Code kopieren bekomme ich folgende Fehlermeldung:Ich versuche, einen Yelp Fusion (V3) API-Aufruf in JavaScript
XMLHttpRequest cannot load https://api.yelp.com/v3/businesses/search?term=restaurant&latitude=40.82783908257346&longitude=-74.10162448883057 .
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'null' is therefore not allowed access.
The response had HTTP status code 500.
Mein AJAX-Aufruf (mit Bearer für Sicherheit geändert):
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.yelp.com/v3/businesses/search?term=restaurant&latitude=40.82783908257346&longitude=-74.10162448883057",
"method": "GET",
"headers": {
"authorization": "Bearer xxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"cache-control": "no-cache",
// "postman-token": "1c66878e-c740-e10d-8d9a-71d731547d2e"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
Gemäß der Dokumentation Yelp - Yelp nicht CORS unterstützen - so CORS ist nicht das Problem.
Mögliches Duplikat von [Wie CORS ermöglichen?] (Http://stackoverflow.com/questions/7067966/how-to-allow-cors) –