存档:TS 重构前基线(lx 聚合源 = isolated-vm 加载器,签名方案已移除)
This commit is contained in:
commit
f289df4cd7
124 files changed
+14110
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { httpFetch } from '../../request.js'
|
||||
|
||||
/**
|
||||
* 创建一个适用于MG的Http请求
|
||||
* @param {*} url
|
||||
* @param {*} options
|
||||
* @param {*} retryNum
|
||||
*/
|
||||
export const createHttpFetch = async(url, options, retryNum = 0) => {
|
||||
if (retryNum > 2) throw new Error('try max num')
|
||||
let result
|
||||
try {
|
||||
result = await httpFetch(url, options).promise
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
return createHttpFetch(url, options, ++retryNum)
|
||||
}
|
||||
if (result.statusCode !== 200 ||
|
||||
(
|
||||
(result.body.code !== undefined
|
||||
? result.body.code
|
||||
: result.body.returnCode !== undefined
|
||||
? result.body.returnCode
|
||||
: result.body.code
|
||||
) !== '000000')
|
||||
) return createHttpFetch(url, options, ++retryNum)
|
||||
if (result.body.data) return result.body.data
|
||||
return result.body
|
||||
}
|
||||
Reference in new issue
Block a user