MCPcopy Index your code
hub / github.com/AutoForgeAI/autoforge / fetchJSON

Function fetchJSON

ui/src/lib/api.ts:39–59  ·  view source on GitHub ↗
(url: string, options?: RequestInit)

Source from the content-addressed store, hash-verified

37const API_BASE = '/api'
38
39async function fetchJSON<T>(url: string, options?: RequestInit): Promise<T> {
40 const response = await fetch(`${API_BASE}${url}`, {
41 ...options,
42 headers: {
43 'Content-Type': 'application/json',
44 ...options?.headers,
45 },
46 })
47
48 if (!response.ok) {
49 const error = await response.json().catch(() => ({ detail: 'Unknown error' }))
50 throw new Error(error.detail || `HTTP ${response.status}`)
51 }
52
53 // Handle 204 No Content responses
54 if (response.status === 204) {
55 return undefined as T
56 }
57
58 return response.json()
59}
60
61// ============================================================================
62// Projects API

Callers 15

listProjectsFunction · 0.85
createProjectFunction · 0.85
getProjectFunction · 0.85
deleteProjectFunction · 0.85
getProjectPromptsFunction · 0.85
updateProjectPromptsFunction · 0.85
updateProjectSettingsFunction · 0.85
resetProjectFunction · 0.85
listFeaturesFunction · 0.85
createFeatureFunction · 0.85
getFeatureFunction · 0.85
deleteFeatureFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected