Created
September 11, 2017 02:09
-
-
Save blogui91/6650fc2f6c9e53947e9c537421b01c54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http from 'axios' | |
import OAuth from 'src/oauth' | |
let oAuth = new OAuth(); | |
http.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest' | |
// Add a request interceptor | |
http.interceptors.request.use(function (config) { | |
config.headers['Authorization'] = oAuth.getAuthHeader() //Example: Bearer asf3132dfsfddffd | |
return config; | |
}, function (error) { | |
// Do something with request error | |
return Promise.reject(error); | |
}); | |
// Add a response interceptor | |
http.interceptors.response.use(function (response) { | |
// Do something with response data | |
return response; | |
}, function (error) { | |
// Do something with response error | |
return Promise.reject(error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment