import useSWR from "swr"; export default function Portainer({ service }) { const config = service.widget; function buildApiUrl(endpoint) { const { url, env } = config; const reqUrl = new URL(`/api/endpoints/${env}/${endpoint}`, url); return `/api/proxy?url=${encodeURIComponent(reqUrl)}`; } const fetcher = (url) => { return fetch(url, { method: "GET", withCredentials: true, credentials: "include", headers: { "X-API-Key": `${config.key}`, "Content-Type": "application/json", }, }).then((res) => res.json()); }; const { data: containersData, error: containersError } = useSWR(buildApiUrl(`docker/containers/json`), fetcher); if (containersError) { return (