技巧
不用try...catch
就能捕获错误的小技巧
export const to = (promise: Promise<any>): Promise<any[]> => {
return new Promise((resolve) => {
promise.then(
(res) => resolve([res, null]),
(err) => resolve([null, err])
);
});
};