MCPcopy
hub / github.com/freeCodeCamp/freeCodeCamp / request

Function request

client/src/utils/ajax.ts:80–97  ·  view source on GitHub ↗
(
  method: 'POST' | 'PUT' | 'DELETE',
  path: string,
  body: unknown
)

Source from the content-addressed store, hash-verified

78}
79
80async function request<T>(
81 method: 'POST' | 'PUT' | 'DELETE',
82 path: string,
83 body: unknown
84): Promise<ResponseWithData<T>> {
85 const options: RequestInit = {
86 ...defaultOptions,
87 method,
88 headers: {
89 'CSRF-Token': getCSRFToken(),
90 'Content-Type': 'application/json'
91 },
92 body: JSON.stringify(body)
93 };
94
95 const response = await fetch(`${base}${path}`, options);
96 return combineDataWithResponse(response);
97}
98
99/** GET **/
100

Callers 8

postFunction · 0.85
putFunction · 0.85
deleteRequestFunction · 0.85
vitest.utils.tsFile · 0.85
challenge.test.tsFile · 0.85
postFunction · 0.85
classroom.test.tsFile · 0.85

Calls 2

getCSRFTokenFunction · 0.85
combineDataWithResponseFunction · 0.85

Tested by 1

postFunction · 0.68