|
@@ -153,6 +153,11 @@ function fetchJSON<T>(
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
error => {
|
|
error => {
|
|
|
|
|
+ // swallow the error if the fetch was cancelled (e.g. by cancelling an AbortController on component unmount)
|
|
|
|
|
+ if (swallowAbortError && error.name === 'AbortError') {
|
|
|
|
|
+ // the fetch request was aborted while reading/parsing the response body
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
// parsing the response body failed
|
|
// parsing the response body failed
|
|
|
reject(
|
|
reject(
|
|
|
new FetchError(
|
|
new FetchError(
|
|
@@ -168,6 +173,7 @@ function fetchJSON<T>(
|
|
|
error => {
|
|
error => {
|
|
|
// swallow the error if the fetch was cancelled (e.g. by cancelling an AbortController on component unmount)
|
|
// swallow the error if the fetch was cancelled (e.g. by cancelling an AbortController on component unmount)
|
|
|
if (swallowAbortError && error.name === 'AbortError') {
|
|
if (swallowAbortError && error.name === 'AbortError') {
|
|
|
|
|
+ // the fetch request was aborted before a response was returned
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
// the fetch failed
|
|
// the fetch failed
|