uppy/packages/@uppy/utils/src/fetchWithNetworkError.js
Renée Kooi c1d15abf10
error on import lint failure + some misc lint fixes (#2813)
Co-authored-by: Artur Paikin <artur@arturpaikin.com>
2021-03-20 11:02:49 +01:00

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)
}
})
}