File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -226,27 +226,28 @@ For older versions, the Node.js standard library does not provide a native imple
226226_ The non-global way (preferred):_
227227
228228``` javascript
229+ import fetch , { FormData } from " node-fetch"
230+
229231// w is a reusable wretch instance
230232const w = wretch ().polyfills ({
231- fetch: require (" node-fetch" ),
232- FormData : require (" form-data" ),
233- URLSearchParams: require (" url" ).URLSearchParams ,
233+ fetch,
234+ FormData ,
234235});
235236```
236237
237238_ Globally:_
238239
239240``` javascript
241+ import fetch , { FormData } from " node-fetch" ;
242+
240243// Either mutate the global object…
241- global .fetch = require (" node-fetch" );
242- global .FormData = require (" form-data" );
243- global .URLSearchParams = require (" url" ).URLSearchParams ;
244+ global .fetch = fetch;
245+ global .FormData = FormData ;
244246
245247// …or use the static wretch.polyfills method to impact every wretch instance created afterwards.
246248wretch .polyfills ({
247- fetch: require (" node-fetch" ),
248- FormData : require (" form-data" ),
249- URLSearchParams: require (" url" ).URLSearchParams ,
249+ fetch,
250+ FormData ,
250251});
251252```
252253
You can’t perform that action at this time.
0 commit comments