MCPcopy Create free account
hub / github.com/9d8dev/directory / handleSubmit

Function handleSubmit

components/admin/url-scraper.tsx:16–42  ·  view source on GitHub ↗
(e: React.FormEvent)

Source from the content-addressed store, hash-verified

14 const [metadata, setMetadata] = useState<ActionState | null>(null);
15
16 const handleSubmit = async (e: React.FormEvent) => {
17 e.preventDefault();
18
19 if (!url) {
20 toast.error("Please enter a URL");
21 return;
22 }
23
24 try {
25 const formData = new FormData();
26 formData.append("url", url);
27
28 //@ts-ignore SOS CAMERON
29 const response = await scrapeUrl(null, formData);
30 if (response?.data) {
31 setMetadata(response);
32 toast.success("Successfully fetched metadata");
33 } else if (response?.error) {
34 toast.error(response.error);
35 } else {
36 toast.error("Failed to fetch metadata");
37 }
38 } catch (error) {
39 console.error("Error scraping URL:", error);
40 toast.error("Failed to scrape URL");
41 }
42 };
43
44 return (
45 <div className="space-y-4">

Callers

nothing calls this directly

Calls 1

scrapeUrlFunction · 0.90

Tested by

no test coverage detected