axios-extensions
axios-extensions copied to clipboard
Adding a possibility to have a custom cache-key generator.
In our API calls we pass a languageid & siteid as header data, which will give us different results. For this it would be handy for us to allow passing a custom cachekey generator with the options.
Do you agree with this idea? If yes, then we can also create a Pull Request with this change if you don't have time to add it?
In throttleAdapterEnhancer & cacheAdapterEnhancer:
var customCacheKey = options.cacheKeyGenerator && options.cacheKeyGenerator(config, buildSortedURL(url, params, paramsSerializer));
var index_1 = customCacheKey || buildSortedURL(url, params, paramsSerializer);
and then in the calling method we can pass the cacheKeyGenerator
to the options.
cacheAdapterEnhancer(axios.defaults.adapter, { cacheKeyGenerator: (config, originalKey) => { /*custom logic*/}});
cool, feel free to submit a pr