Commit e5cfcf8 1 parent b8f9b91 commit e5cfcf8 Copy full SHA for e5cfcf8
File tree 2 files changed +40
-1
lines changed
2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
import CardButton from " ../components/ui/CardButton.astro" ;
3
+ import MyComponent from " ../components/Events.jsx"
3
4
---
4
5
5
6
<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";
67
68
alt =" "
68
69
class =" w-[280px] max-lg:w-[200px]"
69
70
/>
70
- </div >
71
+ </div >
72
+ <MyComponent client:only />
Original file line number Diff line number Diff line change
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 ;
You can’t perform that action at this time.
0 commit comments