21 lines
378 B
TypeScript
21 lines
378 B
TypeScript
'use client';
|
|
|
|
import useSWR from "swr";
|
|
|
|
const fetcher = async (url:any) => await fetch(url).then((res) => res.json());
|
|
|
|
export const EmpireStats = () => {
|
|
const {data} = useSWR('/api/empires',fetcher);
|
|
|
|
let ret;
|
|
|
|
if (data) {
|
|
ret = (
|
|
<div className="text-blue-600">{data.empireCount} Empires</div>
|
|
)
|
|
}
|
|
else {
|
|
ret = (<div></div>)
|
|
}
|
|
return ret
|
|
} |