Weather App Challenge - Please provide longitude as lon and latitude as lat as numbers/floats."}

====EDIT=====
I managed to solve my problem by moving the AJAX request into the geolocation request

if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      userLat = "lat=" + position.coords.latitude;
      userLon = "&lon=" + position.coords.longitude;
      api = 'https://fcc-weather-api.glitch.me/api/current?' + userLat + userLon;
      // =========AJAX REQUEST
      $.getJSON(api, function(json){
        console.log(json);
        $('#data').html(JSON.stringify(json));
      });
    });
  }

I can’t figure out how to send the request with valid values, as the numbers will convert from float into string when sending.

What should I change?

here’s my code:

      <script>
  // ====NAMES FOR LATTITUDE AND LONGITUDE
  var userLat;
  var userLon;

  // ====SET LAT AND LON TO CURRENT GEOPOSITION COORDINATES

  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      userLat = "lat=" + position.coords.latitude;
      userLon = "&lon=" + position.coords.longitude;
    });
  } else {
    // PROMPT NO SUPPORT
  }

  // =========AJAX REQUEST
  var api = 'https://fcc-weather-api.glitch.me/api/current?' + userLat + userLon;
  $.getJSON(api, function(json){
    console.log(json);
    $("#data").html(json);
  });
  

  // Only change code above this line.
</script>
<div id = "data">
  <h4>You are here:</h4>

</div>

@Alonoparag,

what you are doing here:

 userLat = "lat=" + position.coords.latitude;
 userLon = "&lon=" + position.coords.longitude;

is converting the latitude and longitude values to string, since you are adding them to the string prefixes.

I don’t know why converting them to string is an issue since I am guessing you are passing a long string containing values to the weather api.

You are right! though I managed to solve it by moving the AJAX request into the geolocation request