File tree 1 file changed +17
-3
lines changed
1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 1
- import React from "react" ;
1
+ import React , { useEffect , useState } from "react" ;
2
2
3
3
const Visits = ( ) => {
4
+ const [ count , setCount ] = useState ( "" ) ;
5
+ useEffect ( ( ) => {
6
+ const fetchVisits = async ( ) => {
7
+ const data = await fetch (
8
+ import . meta. env . VITE_API_GATEWAY_ENDPOINT + "/visitors" ,
9
+ {
10
+ method : "GET" ,
11
+ }
12
+ ) ;
13
+ const countObj = await new Response ( data . body ) . json ( ) ;
14
+ setCount ( countObj . count ) ;
15
+ } ;
16
+ fetchVisits ( ) ;
17
+ } , [ ] ) ;
4
18
return (
5
19
< div className = "w-min m-auto rounded-3xl p-px bg-gradient-to-b from-blue-300 to-pink-300 dark:from-blue-800 dark:to-purple-800 " >
6
20
< div className = "rounded-[calc(1.5rem-1px)] p-1 py-0 bg-white dark:bg-gray-900" >
7
- < span className = "text-nowrap text-muted-foreground font-light text-sm" >
8
- 153 Visits
21
+ < span className = "text-nowrap text-muted-foreground font-light text-sm px-1 " >
22
+ { count . N } Visits
9
23
</ span >
10
24
</ div >
11
25
</ div >
You can’t perform that action at this time.
0 commit comments