mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-21 17:29:43 +00:00
15 lines
368 B
JavaScript
15 lines
368 B
JavaScript
const NetworkError = require('./NetworkError')
|
|
|
|
/**
|
|
* Wrapper around window.fetch that throws a NetworkError when appropriate
|
|
*/
|
|
module.exports = function fetchWithNetworkError (...options) {
|
|
return fetch(...options)
|
|
.catch((err) => {
|
|
if (err.name === 'AbortError') {
|
|
throw err
|
|
} else {
|
|
throw new NetworkError(err)
|
|
}
|
|
})
|
|
}
|