JSFiddle - React, Tailwind, and code Playground
HTML
<!-- WORK WITH THIS VERSION -->
<script src="https://unpkg.com/axios@0.18.0/dist/axios.min.js"></script>
<!-- FAIL WITH THIS VERSION -->
<script>
axios.interceptors.request.use((config) => {
console.log(config.isBackground)
return config
}, (error) => {
console.log(error.config.isBackground)
return Promise.reject(error)
})
axios.interceptors.response.use((response) => {
console.log(response.config.isBackground)
return response
}, function(error) {
console.log(error.config.isBackground)
return Promise.reject(error)
})
const config = {
isBackground: true
}
axios.get('https://httpbin.org/get', config)
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
axios.get('https://httpbin.org/ge', config)
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
</script>