Skip to content

Switched firebase/database to use the fetch() api #9046

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

betabites
Copy link

Switched out the usage of XMLHttpRequest in @firebase/database for primitives from the more modern and better-supported Fetch API.

Copy link

changeset-bot bot commented May 15, 2025

🦋 Changeset detected

Latest commit: ce3da16

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/database Patch
@firebase/database-compat Patch
firebase Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@betabites betabites marked this pull request as ready for review May 15, 2025 21:50
@betabites betabites requested review from a team, maneesht and aashishpatil-g as code owners May 15, 2025 21:50
@Smrtnyk
Copy link

Smrtnyk commented May 25, 2025

I am a bit intrigued by this part "better-supported"
What exactly does that mean, better supported by who/what?

@betabites
Copy link
Author

betabites commented May 26, 2025

Yeah I could've worded that better. Essentially - correct me if I'm wrong - but in modern cases, fetch is supported in all contexts where XMLHttpRequest is, plus a few additional ones. You can view the MDN docs for XMLHttpRequest and fetch for more information on availability.

Long story short:
In addition, the fetch API is also supported on service workers and server-side environments such as Deno and NodeJS. Using the Fetch API potentially widens support, while also reducing code complexity.

By 'better supported', I simply mean there's slightly more environments where the Fetch API is officially adopted & supported.

@Smrtnyk
Copy link

Smrtnyk commented May 26, 2025

Yeah I could've worded that better. Essentially - correct me if I'm wrong - but in modern cases, fetch is supported in all contexts where XMLHttpRequest is, plus a few additional ones. You can view the MDN docs for XMLHttpRequest and fetch for more information on availability.

Long story short: In addition, the fetch API is also supported on service workers and server-side environments such as Deno and NodeJS. Using the Fetch API potentially widens support, while also reducing code complexity.

By 'better supported', I simply mean there's slightly more environments where the Fetch API is officially adopted & supported.

gotcha, tnx for the explanation
was just curious what it exactly meant in this context of the PR

@betabites
Copy link
Author

Oh right yeah. As mentioned, fetch has slightly better support across platforms and an arguably more readable API. This PR intends to switch @firebase/database to use fetch instead, as it's more readable and has improved cross-platform support.

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.

2 participants