parent
4dca4cc892
commit
ea08864c2a
@ -1,10 +0,0 @@
|
||||
import useSWR from "swr";
|
||||
|
||||
export default function FileContent({ path, loadingValue, errorValue, emptyValue = "" }) {
|
||||
const fetcher = (url) => fetch(url).then((res) => res.text());
|
||||
const { data, error, isLoading } = useSWR(`/api/config/${path}`, fetcher);
|
||||
|
||||
if (error) return errorValue;
|
||||
if (isLoading) return loadingValue;
|
||||
return data || emptyValue;
|
||||
}
|
Loading…
Reference in new issue