Putting Json data in a this.variable but I keep getting the error Uncaught (in promise) TypeError: Cannot set property 'weather' of undefined. Does anyone know how to fix this.
var currentWeather;
function setup() {
createCanvas(400, 400);
currentWeather = new CurrentWeather();
currentWeather.create();
loadJSON(currentWeather.api, currentWeather.gotData);
}
function draw() {
background(0);
}
///////////////////////////////////////////////////////////////////
class CurrentWeather{
create(){
let url = 'https://api.openweathermap.org/data/2.5/weather?q=';
let city = 'Manassas';
let apiKey ='ApiKeyHere';
let units = '&units=imperial';
this.api = url + city + apiKey + units;
this.weather;
}
gotData(data){
this.weather = data;
}
}