summaryrefslogtreecommitdiff
path: root/src/static/main.js
blob: 7bea3893f2013ec1f5b0d30515c5835b34d58587 (plain)
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
30
31
const url = '/text';
const parts = ["top", "program"];
const elements = {};

function get_element(part){
	elements[part] = document.getElementById(part);
}

const program_element = parts.forEach(get_element);

function set_element_text(part, text){
	elements[part].innerHTML = text;
}

async function getEvents() {
  try {
    const response = await fetch(url);
    if (!response.ok) {
      throw new Error(`Response status: ${response.status}`);
    }
		
    const events = await response.json();
		console.log(events)
		
  } catch (error) {
    console.error(error.message);
  }
}

getEvents();