Skip to main content

技巧

不用try...catch就能捕获错误的小技巧

export const to = (promise: Promise<any>): Promise<any[]> => {
return new Promise((resolve) => {
promise.then(
(res) => resolve([res, null]),
(err) => resolve([null, err])
);
});
};