javascript - FCC / Local Weather App / JSON information not displaying info from the OpenWeather API -


i doing freecodecamp local weather app zipline challenge, , got part have extracted location using ip-location api, , supposed use location open weather api information local weather.

i've done , opening json links in new tab in browser(chrome) displays json objects/arrays/info need/etc.

however, try , log info console or change html element's contents specific information callback info, nothing. not errors.

i did research , tried use http instead of https on codepen, didn't solve problem. tried going through youtube tutorials, nobody else encountered issue.

i have included code snippets of code codepen(note: removed api key local weather app)

here useful links: 1. challenge info itself: https://www.freecodecamp.com/challenges/show-the-local-weather 2.the ip api used location: http://ip-api.com/ 3.the open weather api: https://openweathermap.org/current#geo

edit: make question more clear: why info api not display in html elements specified in jquery function?

$(document).ready( function() {          var city;          var countrycode;                    $.getjson("http://ip-api.com/json",function(data2){              city = data2.city;               countrycode = data2.countrycode;                          var api = "api.openweathermap.org/data/2.5/weather?q="+city+","+countrycode+"&appid=mykeygoeshere";            $.getjson(api, function(data3){                      $("cityname").html(data3.city);              $("temperature").html(data3.temp);              $("weather").html(data3.weather[0].description);            });        });    });         
body{    color:#fff;    background-color: #f4495d;  }  .maincontainer{    margin:7% auto;    background-color: #ce2336;    width:50%;  }    h2{    text-align:center;    font-size: 180%;  }    p{    text-align:center;    font-size: 150%;  }
<div class="maincontainer">    <h2>the local weather app</h2>     <div class="coordinates">       <p id="data">something something</p>    </div>     <div class="one-third">       <p id="cityname">yourcity</p>     </div>     <div class="one-third">       <p id="temperature">thetemperature</p>     </div>     <div class="one-third">       <p id="weather">theweather</p>     </div>     <img src="#">  </div>

okay based on comment, need fill html creating, this, have put "#" character in order fill specific element, code should

$(document).ready( function() {     var city;     var countrycode;      $.getjson("http://ip-api.com/json",function(data2){         city = data2.city;          countrycode = data2.countrycode;        var api = "api.openweathermap.org/data/2.5/weather?q="+city+","+countrycode+"&appid=mykeygoeshere";       $.getjson(api, function(data3){                 $("#cityname").text(data3.city);         $("#temperature").text(data3.temp);         $("#weather").text(data3.weather[0].description);       });   }); 

});


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -