Closed slint closed 4 years ago
After some discussion with @zzacharo (CC @ntarocco), it is actually possible to have the desired behaviour by passing both keys to the InvenioSearchApi
class:
const searchApi = new InvenioSearchApi({
baseURL: "https://localhost:5000/api/communities",
url: "",
})
In general though, the discussion should be about whether to provide a wrapper around the axios
config (which is the case now because of the special use of the url
parameter), or to define what kind of arguments are specific to the class and have the rest of them be directly passed to the axios
config.
In the initial discussions when designing react-searchkit
, we did not want to have a wrapper of axios
and define a specific subset of axios
config to pass. That url/baseUrl
has been changed afterwards.
Honestly I find baseUrl
and url
very confusing in axios
: one is the baseUrl indeed, but the other one is for me more a path or a pathname.
I would come back to the initial implementation and allow to pass config directly to axios
without this manipulation of url/baseUrl introduced later on, so it is clear that you have to inject axios
config.
axios supports both
url
andbaseURL
parameters, setting an absoluteurl
though (i.e.url: "https://localhost:5000/api/communities"
, cancelsbaseURL
.Setting
baseURL: config.url
and then expanding the config via...config
, is the equivalent of:When a relative
url
is used (e.g.url: "/api/communities"
), this causes the final requests to be made tobaseURL + url = "/api/communities/api/communities"
.