Files
uni-preset-vue/template/default-ts/uni.promisify.adaptor.ts
2025-11-12 16:51:56 +08:00

13 lines
384 B
TypeScript

uni.addInterceptor({
returnValue (res) {
if (!(!!res && (typeof res === "object" || typeof res === "function") && typeof res.then === "function")) {
return res;
}
return new Promise((resolve, reject) => {
if (!res) {
return resolve(res)
}
res.then((res: [unknown, unknown]) => res[0] ? reject(res[0]) : resolve(res[1]));
});
},
});