Skip to content

Instantly share code, notes, and snippets.

@ryochin
Created September 8, 2019 15:15
Show Gist options
  • Save ryochin/7187763d413a0fc00c42b5cf46b249a5 to your computer and use it in GitHub Desktop.
Save ryochin/7187763d413a0fc00c42b5cf46b249a5 to your computer and use it in GitHub Desktop.
axios.interceptors.request.use((config: Axios.AxiosRequestConfig) => {
if (_.isUndefined(typeof config.params)) {
config.params = {}
}
if (_.isObject(config.params)) {
// prevent caching on IE
if (_.isFunction(URLSearchParams) && config.params instanceof URLSearchParams) {
config.params.append('_', Date.now())
}
else {
config.params._ = Date.now()
}
}
return config
}, (error: any) => {
return Promise.reject(error)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment