UNPKG

382 BJavaScriptView Raw
1const NetworkError = require('@uppy/utils/lib/NetworkError')
2
3/**
4 * Wrapper around window.fetch that throws a NetworkError when appropriate
5 */
6module.exports = function fetchWithNetworkError (...options) {
7 return fetch(...options)
8 .catch((err) => {
9 if (err.name === 'AbortError') {
10 throw err
11 } else {
12 throw new NetworkError(err)
13 }
14 })
15}