I am building an api and i want to be able to call use it like shown below. I want a top level API class, and then each section will be its own submodule, like api.auth will be another imported module, etc. How can i best construct this so that all of the children modules have data from the API class necessary to make calls, such as a baseUrl, and access_token data, etc? The constructor of the API class will take the config and populate a baseUrl field on the api instance object, and I need a way for all child modules to have access to it. I thought about passing it in as a prop and keep following it all the way down, but that just seems clunky
// how do we get the api?
// const api = new API(config);
// how do we use the api?
// api.auth.authorize()
// api.auth.token()
// api.auth.refresh()
// api.shopper.baskets.create()
// api.shopper.customers.create()
// api.shopper.customers.get()