Skip to content

Conversation

@slint
Copy link
Member

@slint slint commented Jan 17, 2020

@slint slint force-pushed the fix-axios branch 4 times, most recently from 289e6a1 to 84847fc Compare January 17, 2020 23:01
}

initAxios(config) {
initAxios({ url, ...config }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slint How is this different than the existing implementation?
Before the code was expecting an object e.g {url: '/me'} and this would end up in the non desired behaviour of calling /me/me when it was triggering a request. Now with the change passing the passing the same object I think it would lead to the same outcome no? Unless you pass explicitly the baseURL parameter which in that case it was already possible before...Do I miss something?

Copy link
Member Author

@slint slint Feb 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since now url is a destructured value from the passed object function argument, it will not be inside the ...config object. This means that it won't be passed at all to the axios.create(...) call

Copy link
Member

@zzacharo zzacharo Feb 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slint But then you will not be able to pass the url parameter at all right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. We have to discuss whether we'll directly pass-through the config to axios.create(...), or if we'll introduce an axiosConfig parameter to the ESSearchApi/InvneioSearchApi class constructor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ntarocco what do you think? I would be in favor I think of name spacing the axios config like axiosConfig and pass it through to axios.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we discussing this? #88
If yes, I should have already replied there :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ntarocco sorry I missed that. So just to confirm what you are proposing is just get through all the config passed to the axios instance right? In that case I wouldn't destructure the url parameter from the config passed and just pass through the config as it is. Then, it would be clear for the users (we should update the docs for that too) that this config is the same with what axios is accepting. @slint WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go with an explicit axiosConfig parameter for the InvenioSearchApi constructor:

export class InvenioSearchApi {
constructor(config) {

So something like:

export class InvenioSearchApi {
  constructor(serializers, axiosConfig, axiosInterceptors) {
    // NOTE: Would still validate the axiosConfig, but inside "initAxios"
    // this.validateConfig(config);
    this.initSerializers(serializers);
    this.initAxios(axiosConfig, axiosInterceptors);
  }
  ...
}

@slint
Copy link
Member Author

slint commented Mar 16, 2020

LGTM :shipit: (I can't review my own PR apparently)

@zzacharo zzacharo merged commit 3a94ada into inveniosoftware:master Mar 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InvenioSearchApi: accidental use of both "baseURL" and "url" config

3 participants