Ну попробуй как нибудь так например
const GeoUrl = 'https://ipinfo.io/json';
function httpGet(url) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onload = function() {
if (this.status == 200) {
resolve(this.response);
} else {
var error = new Error(this.statusText);
error.code = this.status;
reject(error);
}
};
xhr.onerror = function() {
reject(new Error("Network Error"));
};
xhr.send();
});
}
httpGet(GeoUrl)
.then(response => {
let data = JSON.parse(response);
return data;
})
.then(data => httpGet("http://api.openweathermap.org/data/2.5/weather?q="+ data.city+"&units=metric&APPID=061f24cf3cde2f60644a8240302983f2"))
.then(data => {
console.log(data);
return
})