MCPcopy Create free account
hub / github.com/deta/surf / fetch

Method fetch

packages/services/src/lib/sync.ts:62–78  ·  view source on GitHub ↗
(path: string, options: RequestInit = {})

Source from the content-addressed store, hash-verified

60 }
61
62 private async fetch<T>(path: string, options: RequestInit = {}): Promise<T> {
63 const config = this.getConfig()
64 if (!config) {
65 throw new Error('Sync service not configured')
66 }
67
68 // @ts-ignore
69 const json = await window.api.fetchJSON(`${config.baseUrl}${path}`, {
70 ...options,
71 headers: {
72 ...options.headers,
73 Authorization: `Bearer ${config.authToken}`
74 }
75 })
76
77 return json
78 }
79
80 private async get<T>(path: string): Promise<T> {
81 this.log.debug('GET', path)

Callers 5

getMethod · 0.95
postMethod · 0.95
surfProtocolHandleImagesFunction · 0.80
serveFileFunction · 0.80
fetchFilePathFunction · 0.80

Calls 2

getConfigMethod · 0.95
fetchJSONMethod · 0.80

Tested by

no test coverage detected