State and network handling in React
If you’re only using one base url (i.e. addressing your API), you can use this function to set a default baseUrl.
import { setBaseUrl } from "react-ion-store";
setBaseUrl("https://github.com");
If you set this and want to overload the baseUrl, you will have to call setBaseUrl
again or you’ll have to set the baseUrl in your withCall
config object as well.
Likewise, if you’re always using the same headers (f.e. an access token), you can use this function to set them once. Do note that setDefaultHeaders
accepts an object with a key-value pair.
import { setDefaultHeaders } from "react-ion-store";
setDefaultHeaders({ "KEY-STORED-IN-HEADER": "123456798" });
You can overload the headers in your API call or by calling setDefaultHeaders
again.