const to = (promise) => {
return promise
.then(data => ([data, undefined]))
.catch(error => Promise.resolve([undefined, error]));
}
async function userProfile () {
let [user, userErr] = await to(getUser());
if(userErr) throw new Error('Could not fetch user details');
}
----工作日常