-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsketch.js
More file actions
29 lines (23 loc) · 738 Bytes
/
Copy pathsketch.js
File metadata and controls
29 lines (23 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
async function weatherAPI() {
const url = "https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41¤t=temperature_2m,wind_speed_10m&hourly=temperature_2m,relative_humidity_2m,wind_speed_10m";
console.log("Fetching the weather...");
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
const json = await response.json();
console.log(json);
return(json);
} catch (error) {
console.error(error.message);
}
}
function setup() {
createCanvas(400, 400);
const thistxt = weatherAPI();
text(thistxt, 100,100);
}
function draw() {
background(220);
}