Skip to content

Commit

Permalink
Merge pull request #575 from CrOrc/CrOrc-fix-resolve-IE-11
Browse files Browse the repository at this point in the history
Co-authored-by: Jake Champion <me@jakechampion.name>
  • Loading branch information
JakeChampion committed Jun 1, 2020
2 parents a900d7d + 8640749 commit 74e4fe8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions fetch.js
Expand Up @@ -471,19 +471,27 @@ export function fetch(input, init) {
}
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL')
var body = 'response' in xhr ? xhr.response : xhr.responseText
resolve(new Response(body, options))
setTimeout(function() {
resolve(new Response(body, options))
}, 0)
}

xhr.onerror = function() {
reject(new TypeError('Network request failed'))
setTimeout(function() {
reject(new TypeError('Network request failed'))
}, 0)
}

xhr.ontimeout = function() {
reject(new TypeError('Network request failed'))
setTimeout(function() {
reject(new TypeError('Network request failed'))
}, 0)
}

xhr.onabort = function() {
reject(new DOMException('Aborted', 'AbortError'))
setTimeout(function() {
reject(new DOMException('Aborted', 'AbortError'))
}, 0)
}

function fixUrl(url) {
Expand Down

1 comment on commit 74e4fe8

@chriss559
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.