Closed
Description
When using fetchFn
from createApi
, isomorphic-fetch works but cross-fetch fails.
Both seem to run fine in react without RTKQ. But with cross-fetch+RTKQ, a request that should be:
/some-endpoint
is run in the browser as /[object%20Request]
.
Possible I'm an idiot and flubbing the cross-fetch import and that's the problem, but I've tried a few
different import/require default/destructured variations and none seem to solve the issue.
...
const { fetch } = require("cross-fetch"); // doesn't work
// const fetch = require("isomorphic-fetch"); // works
// Define a service using a base URL and expected endpoints
export const pokemonApi = createApi({
reducerPath: "pokemonApi",
baseQuery: fetchBaseQuery({
baseUrl: "https://pokeapi.co/api/v2/",
fetchFn: fetch,
}),
...
Minimal Codesandbox example
https://codesandbox.io/s/vibrant-resonance-cvf7m?file=/src/services/pokemon.ts
Metadata
Metadata
Assignees
Labels
No labels