-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (23 loc) · 988 Bytes
/
Copy pathscript.js
File metadata and controls
28 lines (23 loc) · 988 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
document.addEventListener('DOMContentLoaded', async () => {
const headlineElement = document.getElementById('headline');
const subtextElement = document.getElementById('subtext');
const buttonElement = document.getElementById('join-button');
try {
const response = await fetch('http://localhost:3000/api/hero');
if (!response.ok) {
throw new Error('No Network response');
}
const data = await response.json();
headlineElement.textContent = data.headline;
subtextElement.textContent = data.subtext;
buttonElement.textContent = data.ctaLabel;
buttonElement.addEventListener('click', () => {
window.location.href = 'myprofile.html';
});
} catch (error) {
console.error('Error Loading Content:', error);
headlineElement.textContent = 'Error';
subtextElement.textContent = '';
buttonElement.textContent = '';
}
});