I want this code to set the variable temperature to the temperature. I'm using a library (https://www.npmjs.com/package/openweather-apis)
var temperature;
await weather.getTemperature(async function(err, temp){
console.log(temp)//logs 74.5
temperature = temp
});
console.log(temperature)//logs undefined
How could I have temperature (out of the function) equal to temp (in the function). Outside the function it logs undefined, inside it logs the correct temperature.
Any help would be great!