<!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>Find IP</title>
</head>
<body>
<div class="main-page">
<div class="content-conatainer">
<h1>Определить местоположение</h1>
<div class="data-input">
<input type="text" id="find" class="input-text" name="ip" value="" />
<input type="submit" class="input-button" value="Проверить" />
</div>
<div class="addresult">
<p id="information"></p>
</div>
</div>
</div>
<script src="/index.js"></script>
</body>
</html>
var url = "https://suggestions.dadata.ru/suggestions/api/4_1/rs/iplocate/address?ip=";
var token = "a8173ff8bc750af6a00507e8b50a4bcebf3775e8";
const query = document.getElementById('find').value;
console.log(query);
var options = {
method: "GET",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Token " + token
}
}
fetch(url + query, options)
.then(response => response.json())
.then(({ location }) => {
if (!location) return; // не нашлось
const { data } = location;
const { country, region_with_type, city_with_type } = data
document.getElementById('information').innerHTML += data
})