-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use fetch instead of navigator.beacon #21
Conversation
Updates requests to use the fetch API with keepalive: true instead of navigator.beacon, so that in the future we can set custom HTTP headers. J=SLAP-1968 TEST=manual use the test-site to test that promise rejections are performed as expected
src/infra/HttpRequester.ts
Outdated
xhr.setRequestHeader('Content-Type', 'text/plain;charset=UTF-8'); | ||
xhr.send(data); | ||
return true; | ||
return fetch(url, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetch doesn't work for IE, do we plan on supporting that/need some sort of polyfill?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to do any polyfilling here, answers-core also doesn't do any polyfilling in core but works fine in ie11. This is probably due to cross-fetch already using whatwg-fetch under the hood.
I added import 'core-js/stable'
to the top of the test-site's index.ts and the site works fine in ie11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated HttpRequester to use window.fetch if available the same way core does it, and retested in ie11!
+1 |
Updates requests to use the fetch API with keepalive: true
instead of navigator.beacon, so that in the future we can
set custom HTTP headers.
Updated
npm run dev
to use the esm build, since that's the one the test-site uses.J=SLAP-1968
TEST=manual
use the test-site to test that promise rejections are performed
as expected
test site runs in ie11 if
core-js
is added to the test-site's index.ts