diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-11-20 09:57:08 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-11-20 09:57:08 +0000 |
commit | 9400ed3b3e3bf1c1ce20b9748f4b6e4c0e5b5db7 (patch) | |
tree | b335c1132ded1fd46c1a05451bb5fab1c88a5bb9 /app/assets/javascripts/lib | |
parent | 4f09d099e9fa29659917f87c2dc25f2b9aa05b5e (diff) | |
download | gitlab-ce-9400ed3b3e3bf1c1ce20b9748f4b6e4c0e5b5db7.tar.gz |
Use axios instead of vue resource - step 1
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r-- | app/assets/javascripts/lib/utils/axios_utils.js | 22 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/poll.js | 4 |
2 files changed, 22 insertions, 4 deletions
diff --git a/app/assets/javascripts/lib/utils/axios_utils.js b/app/assets/javascripts/lib/utils/axios_utils.js index 45bff245827..7aeeca3b283 100644 --- a/app/assets/javascripts/lib/utils/axios_utils.js +++ b/app/assets/javascripts/lib/utils/axios_utils.js @@ -1,6 +1,22 @@ import axios from 'axios'; import csrf from './csrf'; -export default function setAxiosCsrfToken() { - axios.defaults.headers.common[csrf.headerKey] = csrf.token; -} +axios.defaults.headers.common[csrf.headerKey] = csrf.token; + +// Maintain a global counter for active requests +// see: spec/support/wait_for_requests.rb +axios.interceptors.request.use((config) => { + window.activeVueResources = window.activeVueResources || 0; + window.activeVueResources += 1; + + return config; +}); + +// Remove the global counter +axios.interceptors.response.use((config) => { + window.activeVueResources -= 1; + + return config; +}); + +export default axios; diff --git a/app/assets/javascripts/lib/utils/poll.js b/app/assets/javascripts/lib/utils/poll.js index 65a8cf2c891..7fca80c2fdb 100644 --- a/app/assets/javascripts/lib/utils/poll.js +++ b/app/assets/javascripts/lib/utils/poll.js @@ -3,7 +3,9 @@ import { normalizeHeaders } from './common_utils'; /** * Polling utility for handling realtime updates. - * Service for vue resouce and method need to be provided as props + * Requirements: Promise based HTTP client + * + * Service for promise based http client and method need to be provided as props * * @example * new Poll({ |