apollo-client
apollo-client copied to clipboard
CurrentFetch is Not a function
$currentFetch is not a function. (In 'currentFetch(chosenURI, options)', 'currentFetch is false') Few days ago everything was working properly in my react native app and then suddenly I get this issue in all of my queries
Intended outcome: to get a data response from the query and the screen get loaded
Actual outcome:
Whenever I run the app and I am getting this error on all the queries which are being fired in the app.
How to reproduce the issue: I am using an IOS Emulator of iPhone X and it doesnt work over there, but strangely in my android device which i run through adb evrything just works fine
Versions System: OS: macOS 12.2
Binaries: Node: 14.16.1 - /usr/local/bin/node npm: 8.2.0 - /usr/local/bin/npm
Browsers: Firefox: 98.0.2 Safari: 15.3
npmPackages: @apollo/client: ^3.3.6 => 3.5.7
I have the same issue, plss someone provide the solution.
Yeah even I am facing the same issue, if you encounter upon any solution to this problem, do respond.
@benjamn can you take a look?, I saw a previous issue where you had worked on currentFetch
Same error here with react-native. Anyone found a solution?
var currentFetch = preferredFetch || utilities.maybe(function () { return fetch; }) || backupFetch;
I see this line returns false which is a boolean not a function. And even if I set fetch
option on the HttpLink I get a similar error
fwiw, I have the same problem in node.
I have no idea if this will help for react native.
I included cross-fetch
in the default HttpLink and it works for me.
It did not work using node-fetch
which is annoying.
My fix was
const fetch = require('cross-fetch');
//....
const client = new ApolloClient({
cache: new InMemoryCache(),
link: new HttpLink({
fetch,
})
});
@evenSosaAkido were you ever able to resolve this? Setting fetch is also not working for me.
@daniel-covelli the issue was resolved in a very unexplicable way for us. I don't know if you use okta. But it tuned out for us that the order we imported the libraries (okta and apollo) caused this error.
So importing apollo BEFORE okta fixed the issue for us.
Sorry I can't give a better answer
@evenSosaAkido yes I believe we are running into the same issue. In our codebase this manifested in our hooks subfolder, by exporting a hook that used @okta before a hook that used @apollo, this error would occur. Weird!
👋 If anyone has a runnable reproduction here, or can create one using our RN testbed https://github.com/apollographql/rn-apollo-client-testbed, that would be much appreciated!
We're closing this issue now but feel free to ping the maintainers or open a new issue if you still need support. Thank you!
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. For general questions, we recommend using StackOverflow or our discord server.