wx-starlock/uni.promisify.adaptor.js

17 lines
348 B
JavaScript
Raw Normal View History

2024-08-06 09:40:20 +08:00
uni.addInterceptor({
2025-02-06 11:37:41 +08:00
returnValue(res) {
if (
!(
!!res &&
(typeof res === 'object' || typeof res === 'function') &&
typeof res.then === 'function'
)
) {
return res
2024-08-06 09:40:20 +08:00
}
return new Promise((resolve, reject) => {
2025-02-06 11:37:41 +08:00
res.then(res => (res[0] ? reject(res[0]) : resolve(res[1])))
})
}
})