async 捕捉错误
-
try…catch
-
返回的数据正确的和错误合并到一起处理
const fn = async() => { let res&&err = await fetchFn().then(res => res).catch(err => err) } -
返回的数据正确的和错误的分开处理
const fn = async() =>{ let [err,res] = await fetchFn().then(res =>[null,res].catch(err => [err,null])) }

浙公网安备 33010602011771号