Skip to content

Commit e5cfcf8

Browse files
committed
local bug?
1 parent b8f9b91 commit e5cfcf8

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/components/Events.astro

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
import CardButton from "../components/ui/CardButton.astro";
3+
import MyComponent from "../components/Events.jsx"
34
---
45

56
<h3 class="font-semibold text-lg text-secondary mb-2 dark:text-white">Today</h3>
@@ -67,4 +68,5 @@ import CardButton from "../components/ui/CardButton.astro";
6768
alt=""
6869
class="w-[280px] max-lg:w-[200px]"
6970
/>
70-
</div>
71+
</div>
72+
<MyComponent client:only/>

src/components/Events.jsx

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React, { useEffect, useState } from 'react';
2+
3+
const Events = () => {
4+
const [events, setEvents] = useState([]);
5+
6+
useEffect(() => {
7+
const fetchData = async () => {
8+
try {
9+
const response = await fetch('http://events.vatsim-scandinavia.org/api/calendars/1/events', {
10+
headers: {
11+
Authorization: 'Bearer 83e0745f-486d-4f73-8184-40c98930380c'
12+
},
13+
mode: 'no-cors' // Add the 'no-cors' mode
14+
});
15+
const data = await response.json();
16+
setEvents(data);
17+
} catch (error) {
18+
console.error('Error fetching events:', error);
19+
}
20+
};
21+
22+
fetchData();
23+
}, []);
24+
25+
return (
26+
<div>
27+
<h1>Events</h1>
28+
<ul>
29+
{events.map(event => (
30+
<li key={event.id}>{event.title}</li>
31+
))}
32+
</ul>
33+
</div>
34+
);
35+
};
36+
37+
export default Events;

0 commit comments

Comments
 (0)