MCPcopy
hub / github.com/freeCodeCamp/freeCodeCamp / get

Function get

client/src/utils/ajax.ts:41–52  ·  view source on GitHub ↗
(
  path: string,
  signal?: AbortSignal
)

Source from the content-addressed store, hash-verified

39// TODO: Might want to handle flash messages as close to the request as possible
40// to make use of the Response object (message, status, etc)
41async function get<T>(
42 path: string,
43 signal?: AbortSignal
44): Promise<ResponseWithData<T>> {
45 const response = await fetch(`${base}${path}`, {
46 ...defaultOptions,
47 headers: { 'CSRF-Token': getCSRFToken() },
48 signal
49 });
50
51 return combineDataWithResponse(response);
52}
53
54async function combineDataWithResponse<T>(response: Response) {
55 const data = (await response.json()) as T;

Callers 7

getSessionUserFunction · 0.85
getUserProfileFunction · 0.85
getShowCertFunction · 0.85
getUsernameExistsFunction · 0.85
getGenerateExamFunction · 0.85
getExamsFunction · 0.85
getExamAttemptsFunction · 0.85

Calls 2

getCSRFTokenFunction · 0.85
combineDataWithResponseFunction · 0.85

Tested by

no test coverage detected