Closed lucasfeliciano closed 1 year ago
At this moment i am using it like import 'fetch-everywhere'
because these reasons https://github.com/wheresrhys/fetch-mock#fetch-is-assigned-to-a-local-variable-not-a-global
@montogeek
In this case you will do like this:
require('fetch-everywhere').polyfill();
I don't think it is a good practice mess with the global object, so if we could keep things in the local scope it is better.
For cases that you need to use in the global scope you can do it explicitly calling the polyfill()
method
I'm tending to make the polyfill optional.
The Idea is to use like:
This will check the environment and depending on the environment it will export one of these:
fetch
defined in the global scope (the case of react-native), it will just export a reference to it.Also we have a option to apply the polyfill:
Doing that we will apply fetch to the global scope.