import { useEffect, useState } from "react"; import { Settings } from "./settings"; export default function SavePage({ settings }: { settings: Settings }) { const [loading, setLoading] = useState(true); const [error, setError] = useState(undefined); async function runFetch() { const resp = await fetch( `${settings.address}/api/trpc/bookmarks.bookmarkLink`, { method: "POST", }, ); if (!resp.ok) { setError("Something went wrong: " + (await resp.json())); } setLoading(false); } useEffect(() => { runFetch(); }, []); if (loading) { return
Loading ...
; } if (error) { return
{error} ...
; } return (
SAVED!
); }