提交 b7e19952 编写于 作者: D DCloud_LXH

feat: add uni.interceptors.promiseInterceptor

上级 345d8889
......@@ -2,7 +2,8 @@ const base = [
'base64ToArrayBuffer',
'arrayBufferToBase64',
'addInterceptor',
'removeInterceptor'
'removeInterceptor',
'interceptors'
]
const network = [
......
......@@ -105,7 +105,7 @@ function queue (hooks, data) {
}
if (res === false) {
return {
then () {}
then () { }
}
}
}
......@@ -185,10 +185,14 @@ export const promiseInterceptor = {
if (!isPromise(res)) {
return res
}
return res.then(res => {
return res[1]
}).catch(res => {
return res[0]
return new Promise((resolve, reject) => {
res.then(res => {
if (res[0]) {
reject(res[0])
} else {
resolve(res[1])
}
})
})
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册