I try to use whatwg-fetchand babel-polyfill. It is still not working. I had checked fetch does work in my browser, but it is not working in relay-runtime.
Uncaught TypeError: fetch is not a function
at Object.requestStream (index.js:70194)
at RelayModernEnvironment.streamQuery (index.js:69649)
at ReactRelayQueryRenderer._fetch (index.js:65522)
at new ReactRelayQueryRenderer (index.js:65382)
at common.js:26301
at measureLifeCyclePerf (common.js:26082)
at ReactCompositeComponentWrapper._constructComponentWithoutOwner (common.js:26300)
at ReactCompositeComponentWrapper._constructComponent (common.js:26286)
at ReactCompositeComponentWrapper.mountComponent (common.js:26194)
at Object.mountComponent (common.js:5603)
I solve the problem.
How did you solve the problem, brother?
I forgot do this:
function fetchQuery(
operation,
variables,
cacheConfig,
uploadables,
) {
return fetch('/graphql', {
method: 'POST',
headers: {
// Add authentication and other headers here
'content-type': 'application/json'
},
body: JSON.stringify({
query: operation.text, // GraphQL text from input
variables,
}),
}).then(response => {
return response.json();
});
}
I just added this to my Environment. You can see here.