You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
11 lines
374 B
11 lines
374 B
9 months ago
|
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)
|
||
|
}
|