Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a69bded

Browse files
authoredJun 21, 2024··
Merge pull request #8 from vishnumohanan404/dev
visitor get api integration completed
2 parents 8c30eac + c8756b8 commit a69bded

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed
 

‎src/components/visits.jsx

+17-3
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">
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
923
</span>
1024
</div>
1125
</div>

0 commit comments

Comments
 (0)
Please sign in to comment.