MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / makeRequest

Function makeRequest

apps/api/scripts/test-manage-api.ts:34–78  ·  view source on GitHub ↗
(
  method: string,
  path: string,
  body?: any,
)

Source from the content-addressed store, hash-verified

32const results: TestResult[] = [];
33
34async function makeRequest(
35 method: string,
36 path: string,
37 body?: any,
38): Promise<TestResult> {
39 const url = `${API_BASE_URL}${path}`;
40 const headers: Record<string, string> = {
41 'openpanel-client-id': CLIENT_ID,
42 'openpanel-client-secret': CLIENT_SECRET,
43 };
44
45 // Only set Content-Type if there's a body
46 if (body) {
47 headers['Content-Type'] = 'application/json';
48 }
49
50 try {
51 const response = await fetch(url, {
52 method,
53 headers,
54 body: body ? JSON.stringify(body) : undefined,
55 });
56
57 const data = await response.json().catch(() => ({}));
58
59 return {
60 name: `${method} ${path}`,
61 method,
62 url,
63 status: response.status,
64 success: response.ok,
65 error: response.ok ? undefined : data.message || 'Request failed',
66 data: response.ok ? data : undefined,
67 };
68 } catch (error) {
69 return {
70 name: `${method} ${path}`,
71 method,
72 url,
73 status: 0,
74 success: false,
75 error: error instanceof Error ? error.message : 'Unknown error',
76 };
77 }
78}
79
80async function testProjects() {
81 console.log('\n📁 Testing Projects endpoints...\n');

Callers 3

testProjectsFunction · 0.85
testClientsFunction · 0.85
testReferencesFunction · 0.85

Calls 3

fetchFunction · 0.50
stringifyMethod · 0.45
catchMethod · 0.45

Tested by

no test coverage detected