HTML5 getirme API'sini kullanıyorum.HTML5 getirme API'sini kullanarak Access-Control-Allow-Origin üstbilgisine izin ver API
var request = new Request('https://davidwalsh.name/demo/arsenal.json');
fetch(request).then(function(response) {
// Convert to JSON
return response.json();
}).then(function(j) {
// Yay, `j` is a JavaScript object
console.log(JSON.stringify(j));
}).catch(function(error) {
console.log('Request failed', error)
});
Normal json'u kullanabiliyorum ama yukarıdaki api url verisini alamıyorum. epascarello Dediğim gibi
Fetch API cannot load https://davidwalsh.name/demo/arsenal.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Üçüncü taraf sunucunun ayarlaması gerekiyor, istemcilerde yapabileceğiniz hiçbir şey yok. – epascarello
@epascarello: Müşteri tarafında yapabiliriz. Sahnenin ardında XHR İsteği devam ediyor. Lütfen bunu kontrol edin "https: // davidwalsh.name/fetch" – iNikkz