xxxxxxxxxx
42
function getWeather(url) {
fetch(url)
.then(response => {
return response.json()
})
.then(json => {
console.log(json);
displayText = json[0].RealFeelTemperature.Value < 19 ? 'Ja' : 'Nee, niet nodig';
detailText = 'Temp. ' + json[0].RealFeelTemperature.Value + ' graden \n';
detailText += 'Neerslag ' + json[0].Rain.Value + ' ' + json[0].Rain.Unit;
return json
})
}
let weatherData = null;
let displayText = 'blah';
let detailText = '';
function setup() {
createCanvas(400, 400);
weatherData = getWeather('https://dataservice.accuweather.com/forecasts/v1/hourly/1hour/249209?language=nl-nl&details=true&metric=true&apikey=dSOITZZpdU24COK3qLHJ4UnURRvAgFmg', weatherData);
}
function draw() {
background(22);
fill(255);
noStroke();
textAlign(CENTER);
textSize(23)
text('Moet ik een jas aan?', width/2, height/4)
text(displayText, width/2, height/2)
textSize(13)
text(detailText, width/2, height/2 + (height/8))
}