Skip to content

Commit df85e01

Browse files
visitor get api integration completed
1 parent 45a35a8 commit df85e01

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/components/visits.jsx

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
import React from "react";
1+
import React, { useEffect, useState } from "react";
22

33
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+
}, []);
418
return (
519
<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 ">
620
<div className="rounded-[calc(1.5rem-1px)] p-1 py-0 bg-white dark:bg-gray-900">
721
<span className="text-nowrap text-muted-foreground font-light text-sm">
8-
153 Visits
22+
{count.N} Visits
923
</span>
1024
</div>
1125
</div>

0 commit comments

Comments
 (0)