MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / fetchData

Function fetchData

website/src/pages/Explore.tsx:894–917  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

892 if (!backend && !cypherQuery) return;
893
894 const fetchData = async () => {
895 setLoading(true);
896 setError(null);
897 try {
898 const url = new URL("/api/graph", backend || window.location.origin);
899 if (repoPath) url.searchParams.append("repo_path", repoPath);
900 if (cypherQuery) url.searchParams.append("cypher_query", cypherQuery);
901
902 const response = await fetch(url.toString());
903 if (!response.ok) {
904 const errData = await response.json().catch(() => ({}));
905 throw new Error(errData.detail || `Server error (${response.status})`);
906 }
907
908 const data = await response.json();
909 setGraphData(data);
910 } catch (err: any) {
911 console.error("Fetch Error:", err);
912 setError(err.message);
913 toast.error("Failed to connect to local index: " + err.message);
914 } finally {
915 setLoading(false);
916 }
917 };
918
919 fetchData();
920 }, [backend, repoPath, cypherQuery]);

Callers 1

ExploreFunction · 0.70

Calls 3

errorMethod · 0.80
appendMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected