Skip to content
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

Merged
merged 9 commits into from
Mar 22, 2022
Merged

use fetch instead of navigator.beacon #21

merged 9 commits into from
Mar 22, 2022

Conversation

oshi97
Copy link
Contributor

@oshi97 oshi97 commented Mar 21, 2022

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

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
@oshi97 oshi97 requested a review from a team March 21, 2022 19:44
test-site/src/index.ts Outdated Show resolved Hide resolved
test-site/webpack.config.js Outdated Show resolved Hide resolved
@oshi97 oshi97 requested review from cea2aj and yen-tt March 21, 2022 20:50
xhr.setRequestHeader('Content-Type', 'text/plain;charset=UTF-8');
xhr.send(data);
return true;
return fetch(url, {
Copy link
Contributor

@yen-tt yen-tt Mar 21, 2022

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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!

@oshi97 oshi97 requested a review from yen-tt March 21, 2022 22:00
@cea2aj
Copy link
Member

cea2aj commented Mar 21, 2022

+1

@oshi97 oshi97 merged commit 92246da into main Mar 22, 2022
@oshi97 oshi97 deleted the dev/use-post branch March 22, 2022 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants