Project -2 weather forcasting

There is a small change in the url of weather bit please check , city option is not available and something like “minute” is added

Pls tell me what to do …

1 Like

I noted your query, i will reach you soon.

2 Likes

I,m waiting, thankyou.

1 Like
<body>
	
	<p id="output">Enter the name of any city to check the temperature</p>
		<input id="city">
		<button onclick="update_user()">Submit</button>
	<script type="text/javascript">
		function update_user(){
			
		city_name=document.getElementById("city").value;
		httpRequest= new XMLHttpRequest();
		url= "https://api.weatherbit.io/v2.0/current?city=" + city_name + "&key=fdf776c992894618b89073796101ee9d";
		httpRequest.open("GET",url);
		httpRequest.send();

		httpRequest.onreadystatechange = function(){
			if(this.readyState==4 && this.status==200){
				weather_data=JSON.parse(this.responseText);
				document.getElementById("output").innerHTML= "The temperature in " + city_name + " is " + weather_data.data[0].temp + "°F";
			}
		}
		}
	</script>


</body>

Try this code and let us know if your query resolved.

2 Likes