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

fix: get proper binding for the fetch function #713

Closed
wants to merge 1 commit into from

Conversation

alexjoverm
Copy link
Contributor

Hey team, this issue is important as it makes js-client unusable. The fix is on the binding of fetch which is bound to the instance of the client instead of window. Check this stackoverflow thread for more info: https://stackoverflow.com/questions/44720448/fetch-typeerror-failed-to-execute-fetch-on-window-illegal-invocation

Btw, I know the type any is not ideal but as this is blocking we can improve that later.

Pull request type

  • Bugfix

How to test this PR

  • Switch to the branch of this PR
  • Open one terminal (terminal A) - run npm run build to ensure you're using latest js-client dist
  • Open another terminal (terminal B) - run cd playground-svelte, run npm i, and run npm run demo. Open http://localhost:5174/ in the browser and all should be good (as in image 1 below) - ISSUE FIXED
  • Now in src/sbFetch line 33, change is as it was before this.fetch = $c.fetch(args) || fetch(args), and in terminal A run npm run build again
  • Reload the page on the browser, open the console, and you'll see the fetch function is failing (as in image 2 below) - CURRENT ISSUE

IMAGE 1 - ALL GOOD
Screenshot 2023-12-15 at 17 04 04

IMAGE 2 - FETCH FAILING
Screenshot 2023-12-15 at 17 05 02

@alexjoverm
Copy link
Contributor Author

Closing in favor of #712

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.

1 participant