New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optional config #148
base: master
Are you sure you want to change the base?
Add optional config #148
Conversation
@ShMcK Tests are failing and you've left a console.log statement in the code. Please revise :) I think it'd be wise if passed "local" config would extend from the default config. E.g. using Object.assign. |
Since this pull request is superseding #145, could we create the options object like below? Otherwise this will not provide the same functionality. I need a way to pass in data for the const options = {
method: 'POST',
data: JSON.stringify({
data: resource
}),
...axiosConfig,
}; |
@egeriis, good idea. I've implemented a config override, rather than config replacement, in 6956c82. @jonathonwalz, I've also implemented the config override to fit your use case in 6956c82. I've also cleaned up and squashed commits. |
Resolves redux-json-api#146. overwrites existing config, rather than replacing it, as recommended by @egeriis.
@jonathonwalz Good point! Do you need to set meta for all requests though? In your PR it's per-request? @ShMcK Good job, will take another look :) |
Since this hasn't been merged yet, I've run into a use-case where I need to modify the readResource request as well (modify the headers based on request). Would it make sense to include a similar change to allow modifying the axiosConfig for readResource too? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small typo
return (dispatch, getState) => { | ||
dispatch(apiWillDelete(resource)); | ||
|
||
const { axiosConfig } = getState().api.endpoint; | ||
const axiosConfig = getState().api.endpoint.axios; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seem to be a typo here, endpoint.axios
should be endpoint.axiosConfig
. If this isn't caught be any tests, we should make that happen 😄
@ShMcK Sorry for letting this stall, I hope you don't mind revisiting this and revising this PR from my review ❤️ |
Just curious about what is happening with this PR I have a use case that really needs these changes and wondering if I can help move it along in any way. |
Resolves #146.
Allow the ability to overwrite axiosConfig for update & delete resource requests. See PR #146.
This allows the client to make requests at different endpoints.
In the example below, the endpoint for v2 is overwritten with v2.1.
const customConfig = const config = {
...store.getState().api.endpoint.axiosConfig,
baseURL:
https://host.com/v2.1/
, // rather than v2};
dispatch(deleteResource(entity, customConfig));
Other axiosConfig properties could be overridden as well, such as host, timeout, etc.