Issues around `initializeNetworkHelpers` `TypeError: this.getToken is not a function`
Created by: beezenees
Regarding the initialization of network helpers, it would seem to me that the initializeNetworkHelpers
function is not performing in the way it should be. It looks like what is happening is when I pass in a custom config, it inevitably resets itself to the DEFAULT_NETWORK_HELPERS
config, which for me, still is not working (the this.getToken is not a function
error occurs with me trying to use an overwritten config, or the default config.
Repo: https://github.com/Pinesy/radical
The custom config i'm trying to use (just trying to overwrite the getToken
method)
const networkHelpers = {
getToken: () => sessionStorage.getItem("auth_token")
};
initializeNetworkHelpers(networkHelpers);
I am calling initializeNetworkHelpers
before any network requests being made.
This is an image of the error:
When I click through to the error spot:
Additional info:
This is the resource I am trying to perform the retrieve
method on.
import { createResource } from "@brigad/redux-rest-easy";
const products = createResource("products")({
retrieve: {
method: "GET",
url: "/products",
afterHook: () => console.log("Products retrieved successfuly")
}
});
const {
actions: { retrieve: { perform: retrieveProducts } },
selectors: {
resource: { getResource: getProducts },
retrieve: { request: { isPerforming: isRetrievingProducts } }
}
} = products;
export { retrieveProducts, getProducts, isRetrievingProducts };
The url is /products
because in my CRA config, I have my local API proxied, "proxy": "http://localhost:8080/api"