Vermonster/fhir-kit-client

Browser compatibility issue

Closed this issue · 5 comments

I'm using the fhir-kit-client library to read FHIR data from a react app in-browser. Using webpack to bundle the npm installation of fhir-kit-client into my bundle.js file. Since this runs in-browser, the URLSearchParams API is already present (provided by browser). Therefore, the line at the top of fhir-kit-client/lib/client.js, const { URLSearchParams } = require('url');, is overriding the provided URLSearchParams and resulting in the error 'client.js:531 Uncaught TypeError: URLSearchParams is not a constructor`.

Expected Behavior

I shouldn't see any errors in my browser console when I use client.search

Actual Behavior

I get
client.js:531 Uncaught TypeError: URLSearchParams is not a constructor

@harshita-gupta we are planning to address this issue shortly. And, somewhat related, we will also include an example of a SMART public authentication workflow in the examples directory.

Thanks for your feedback!

Thanks very much, @bkaney! Any idea when that might be released, so I can plan development accordingly?

@harshita-gupta can you try out this branch to see if it works for you: #67

@bkaney This works great, thanks! Let me know when it's pushed to npm so that I can update my package.json.

See release 0.4.2, up on npmjs now.