这是我的代码
var Geo= {};
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
}
else {
alert('Geolocation is not supported');
}
function showPosition(position) {
Geo.lat = position.coords.latitude;
Geo.lng = position.coords.longitude;
}
// var btc = document.querySelector('#price');
//listen for clicks
window.onload = function() {
// window.onload = function() { if want to load it immediately without d click of a btn
//make request
var btcP = new XMLHttpRequest();
var requestUrl ="https://fcc-weather-api.glitch.me/api/current?lat=" + Geo.lat + "&lon=" + Geo.lng + "";
console.log(requestUrl);