MCPcopy
hub / github.com/1Panel-dev/KubePi / promise

Function promise

web/dashboard/src/plugins/request.js:135–146  ·  view source on GitHub ↗
(request, loading = {})

Source from the content-addressed store, hash-verified

133
134/* 简化请求方法,统一处理返回结果,并增加loading处理,这里以{success,data,message}格式的返回值为例,具体项目根据实际需求修改 */
135const promise = (request, loading = {}) => {
136 return new Promise((resolve, reject) => {
137 loading.status = true
138 request.then(response => {
139 resolve(response.data)
140 loading.status = false
141 }).catch(error => {
142 reject(error)
143 loading.status = false
144 })
145 })
146}
147
148export const get = (url, data, loading) => {
149 return promise(request({url: url, method: "get", params: data}), loading)

Callers 7

getFunction · 0.70
postFunction · 0.70
putFunction · 0.70
delFunction · 0.70
delWithDataFunction · 0.70
postFileFunction · 0.70
patchFunction · 0.70

Calls 1

resolveFunction · 0.50

Tested by

no test coverage detected