22

I have a project that uses fetch polyfill from isomorphic-fetch. I would like to use URLSearchParams with it to submit POST data. For fetch to support URLSearchParams it first checks if it is available in global object. I though to use this polyfill for it but I don't know how to properly import it in webpack, so that fetch notices that it is available.

How can I accomplish this? Thank you!

starball
  • 20,030
  • 7
  • 43
  • 238
Max Semikin
  • 974
  • 1
  • 11
  • 19

2 Answers2

25

I had the same issue, had to switch to other polyfill to make it work, try this:

https://github.com/jerrybendy/url-search-params-polyfill

then simply add it to your webpack config:

entry: {
  bundle: [
    ...
    'url-search-params-polyfill',
    './src/entry'
  ]
}
peter46
  • 389
  • 4
  • 9
-1

How to include the WebReflection/url-search-params polyfill into webpack bundle:

entry: [
  'url-search-params/build/url-search-params.max',
  ...otherPolyfills,
  './your.entrypoint.jsx',
],
Dmitrii Sorin
  • 3,855
  • 4
  • 31
  • 40
  • 2
    This one is deprecated, it mentions to use https://github.com/ungap/url-search-params instead. – Hinrich Jan 08 '20 at 10:54