Skip to content

Instantly share code, notes, and snippets.

@mikaelhadler
Last active April 9, 2019 18:20
Show Gist options
  • Save mikaelhadler/f2be4dfdd688b51a3683785cf68593eb to your computer and use it in GitHub Desktop.
Save mikaelhadler/f2be4dfdd688b51a3683785cf68593eb to your computer and use it in GitHub Desktop.
import axios from 'axios'
axios.interceptors.request.use(function (config) {
// Do something before request is sent
return config
}, function (error) {
// Do something with request error
console.log('Request error: ', error)
return Promise.reject(error)
})
axios.interceptors.response.use(function (response) {
// Do something with response data
console.log('Response OK: ', response)
return response
}, function (error) {
// Do something with response error
console.log('Error: ', error)
return Promise.reject(error)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment