Need help for Weather app - Weather from API does not show up

Hello, I’m challenging for Weather app now.
I could show ‘Location’ through API but ‘Weather’ and ‘Temperature’ through API does not show up.
Could anybody give me advice? Thank you so much in advance.


<div class="container">
  <h1> Show you the weahter </h1>
  <span id="location"> </span>
  <span id="weather"> </span> 
  <span id="temp"></span> 


    var OpenWeatherKey = '4178c7c00c8613f9b84c4784af4fff3e';
    var locationUrl =  '';

    function getLocation(){
    		url : locationUrl,
    		dataType: "json",
    		success : function(data){
    			var country = data['country_name'];
    			var city = data['city'];
    			var latitude = data['latitude'];
    			var longitude = data['longitude'];
    			$('#location').html(city + ', ' + country);
                var Weather = "" + latitude + "&lon=" + longitude + "&units=" + tempUnit + "&APPID=" +OpenWeatherKey;

    function getWeather(url){
    		success: function(data){
    	    var weather = data['weather'][0]['main'];
    	    var temp = data['main']['temp'];


Codepen link

I’m sorry I cannot show my HTML code properly.
This is codepen link.

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

Your code on Codepen doesn’t exactly match your copied code. In the getLocation function you end all variables with a dot, var latitude = data.latitude.;, which shouldn’t be there: var latitude = data.latitude; Note that Codepen gives an error (red bubble with an exclamation mark).

Besides that, you are using tempUnit (var Weather = "" + latitude + "&lon=" + longitude + "&units=" + tempUnit + "&APPID=" + OpenWeatherKey;) but is not defined.

1 Like

Thank you so much. I could find what was the problem.
I will follow the instruction when I post next time. :slight_smile:

1 Like