MCPcopy Index your code
hub / github.com/apache/devlake / request

Function request

config-ui/src/utils/request.ts:50–84  ·  view source on GitHub ↗
(path: string, config?: RequestConfig)

Source from the content-addressed store, hash-verified

48);
49
50export const request = (path: string, config?: RequestConfig) => {
51 const { method = 'get', data, timeout, headers, signal } = config || {};
52
53 const cancelTokenSource = axios.CancelToken.source();
54 const token = localStorage.getItem('accessToken');
55 const h = { ...headers };
56 if (token) {
57 h.Authorization = `Bearer ${token}`;
58 }
59
60 const params: any = {
61 baseURL: config?.baseURL,
62 url: path,
63 method,
64 timeout,
65 headers: h,
66 cancelToken: cancelTokenSource?.token,
67 };
68
69 if (['GET', 'get'].includes(method)) {
70 params.params = data;
71 } else {
72 params.data = data;
73 }
74
75 const promise = instance.request(params).then((resp) => resp.data);
76
77 if (signal) {
78 signal.addEventListener('abort', () => {
79 cancelTokenSource?.cancel();
80 });
81 }
82
83 return promise;
84};

Callers 15

migrateFunction · 0.90
pingFunction · 0.90
versionFunction · 0.90
listFunction · 0.90
getFunction · 0.90
createFunction · 0.90
removeFunction · 0.90
updateFunction · 0.90
testFunction · 0.90
testOldFunction · 0.90
listFunction · 0.90
boardsFunction · 0.90

Calls

no outgoing calls

Tested by 1

testFunction · 0.72