MCPcopy
hub / github.com/opentrace/opentrace / get

Method get

ui/src/store/serverStore.ts:104–121  ·  view source on GitHub ↗
(
    path: string,
    params?: Record<string, string>,
  )

Source from the content-addressed store, hash-verified

102 // ---- Helpers --------------------------------------------------------
103
104 private async get<T>(
105 path: string,
106 params?: Record<string, string>,
107 ): Promise<T> {
108 const base = this.baseUrl.endsWith('/') ? this.baseUrl : this.baseUrl + '/';
109 const url = new URL(path.startsWith('/') ? path.slice(1) : path, base);
110 if (params) {
111 for (const [k, v] of Object.entries(params)) {
112 if (v !== undefined && v !== '') url.searchParams.set(k, v);
113 }
114 }
115 const res = await fetch(url.toString());
116 if (!res.ok) {
117 const body = await res.text().catch(() => '');
118 throw new Error(`Server error ${res.status}: ${body}`);
119 }
120 return res.json() as Promise<T>;
121 }
122
123 private async post<T>(path: string, body: unknown): Promise<T> {
124 const base = this.baseUrl.endsWith('/') ? this.baseUrl : this.baseUrl + '/';

Callers 3

getIndexProgressMethod · 0.95
searchNodesMethod · 0.95
listNodesMethod · 0.95

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected