24.05.2022, 15:46
Hallo ich versuche einen Crawler zu bauen, um an die id's von z.b Städten von wikidata zu kommen. Beim fetchen der Wikidata APi bekomme ich dann aber folgenden Fehler. Wie kann ich den Fehler umgehen. Habe schon so ein Addon für google gefunden. Aber damit geht das bei mir nicht.
Vielen dank schonmal für eure Vorschläge.
Access to fetch at 'https://www.wikidata.org/w/api.php?...itles=Dresden&props=descriptions&languages=en' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Vielen dank schonmal für eure Vorschläge.
Access to fetch at 'https://www.wikidata.org/w/api.php?...itles=Dresden&props=descriptions&languages=en' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>
<script>
url = "https://www.wikidata.org/w/api.php?...itles=Dresden&props=descriptions&languages=en"
Promise.all([
fetch(url, {
}).then(response =>{
if(response.ok)
return response.json();
else
alert(response.status)
}),
]).then(res => {
output = res;
console.log(output)
})
</script>