Ссылка API работает, но по какой -то причине, когда я пытаюсь получить ее, она показывает 404 на консоли < /p>
Консоль получает: 404 (не найдено) < /p>
const outputElement = document.createElement("h1");
document.body.appendChild(outputElement);
const reqOptions = {
method: "GET",
Headers: "Access-Control-Allow-Origin",
};
function getJson(urlApi) {
fetch(urlApi)
.then((response) => {
if (!response.ok) {
throw new Error("Network is not ok");
}
return response.json();
})
.then((data) => {
console.log(data);
outputElement.textContent = JSON.stringify(data.location);
})
.catch((error) => {
console.error(error);
});
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... urning-404