MCPcopy Index your code
hub / github.com/OpenAgentPlatform/Dive / fetch

Method fetch

electron/main/oap.ts:131–153  ·  view source on GitHub ↗
(url: string, options: RequestInit = {})

Source from the content-addressed store, hash-verified

129 }
130
131 fetch<T>(url: string, options: RequestInit = {}) {
132 const token = getToken()
133 if (!token) {
134 this.logout()
135 throw new Error("not logged in")
136 }
137
138 return fetch(`${OAP_ROOT_URL}${url}`, {
139 ...options,
140 headers: {
141 ...options.headers,
142 Authorization: `Bearer ${token}`,
143 "User-Agent": `Dive Desktop(${CLIENT_ID})-${packageJson.version}`,
144 },
145 }).then((res) => res.text() as Promise<T>)
146 .then(text => {
147 try {
148 return JSON.parse(text as string) as T
149 } catch (_error) {
150 return text as T
151 }
152 })
153 }
154
155 getMCPTags() {
156 return this.fetch<{ body: { tag: string, count: number }[], error: null, status_code: number, status_message: string }>("/api/v1/mcp/tags")

Callers 11

logoutMethod · 0.95
getMCPTagsMethod · 0.95
getMCPServersMethod · 0.95
searchMCPServerMethod · 0.95
modelDescriptionMethod · 0.95
applyMCPServerMethod · 0.95
getMCPServerConfigMethod · 0.95
getMeMethod · 0.95
getUsageMethod · 0.95
limiterCheckMethod · 0.95
initProtocolFunction · 0.80

Calls 2

logoutMethod · 0.95
getTokenFunction · 0.85

Tested by

no test coverage detected