refactor 'cycle_analytics' to use axios
This commit is contained in:
parent
149e91b50e
commit
0421fbcdad
2 changed files with 17 additions and 15 deletions
|
@ -82,7 +82,6 @@ export default () => {
|
|||
|
||||
this.service
|
||||
.fetchCycleAnalyticsData(fetchOptions)
|
||||
.then(resp => resp.json())
|
||||
.then((response) => {
|
||||
this.store.setCycleAnalyticsData(response);
|
||||
this.selectDefaultStage();
|
||||
|
@ -116,7 +115,6 @@ export default () => {
|
|||
stage,
|
||||
startDate: this.startDate,
|
||||
})
|
||||
.then(resp => resp.json())
|
||||
.then((response) => {
|
||||
this.isEmptyStage = !response.events.length;
|
||||
this.store.setStageEvents(response.events, stage);
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
import Vue from 'vue';
|
||||
import VueResource from 'vue-resource';
|
||||
|
||||
Vue.use(VueResource);
|
||||
import axios from '~/lib/utils/axios_utils';
|
||||
|
||||
export default class CycleAnalyticsService {
|
||||
constructor(options) {
|
||||
this.requestPath = options.requestPath;
|
||||
this.cycleAnalytics = Vue.resource(this.requestPath);
|
||||
this.axios = axios.create({
|
||||
baseURL: options.requestPath,
|
||||
});
|
||||
}
|
||||
|
||||
fetchCycleAnalyticsData(options = { startDate: 30 }) {
|
||||
return this.cycleAnalytics.get({ cycle_analytics: { start_date: options.startDate } });
|
||||
return this.axios
|
||||
.get('', {
|
||||
params: {
|
||||
'cycle_analytics[start_date]': options.startDate,
|
||||
},
|
||||
})
|
||||
.then(x => x.data);
|
||||
}
|
||||
|
||||
fetchStageData(options) {
|
||||
|
@ -19,12 +23,12 @@ export default class CycleAnalyticsService {
|
|||
startDate,
|
||||
} = options;
|
||||
|
||||
return Vue.http.get(`${this.requestPath}/events/${stage.name}.json`, {
|
||||
params: {
|
||||
cycle_analytics: {
|
||||
start_date: startDate,
|
||||
return this.axios
|
||||
.get(`events/${stage.name}.json`, {
|
||||
params: {
|
||||
'cycle_analytics[start_date]': startDate,
|
||||
},
|
||||
},
|
||||
});
|
||||
})
|
||||
.then(x => x.data);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue