Skip to content Skip to sidebar Skip to footer

How To Use This Api To Return The Temperature? With Javascript?

Hi I was given this code and want to build upon it so that the temperature is also returned. I am using OpenWeatherMap API. Here is the code that I need to pull the information fro

Solution 1:

Here's how I'd do it.

// Get the temperature
var temp = json.main.temp

// Get your div you want to put it in
var mydiv = document.getElementById('mydivid')

// Set the inner HTML as that temperature (plus units, in your case, kelvin I guess)
mydiv.innerHTML(temp + "K")

Post a Comment for "How To Use This Api To Return The Temperature? With Javascript?"