【发布时间】:2020-08-27 16:27:45
【问题描述】:
所以我有一个像这样的中止控制器的获取:
async function fn() {
const abortController = new AbortController();
try {
const response = await fetch(/* ... */, { signal: abortController.signal });
// ...
} catch (e) {
// how can I tell if `e` is from a network error (e.g. offline)
// or an error from an abort
}
}
如何判断e 是网络错误还是中止错误?
【问题讨论】:
标签: javascript fetch-api