summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/environments/services/environments_service.js.es6
blob: fab8d977f5852ec4da8af262115d98ba4e956ef7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* globals Vue */
/* eslint-disable no-unused-vars, no-param-reassign */

class EnvironmentsService {

  constructor(root) {
    Vue.http.options.root = root;

    this.environments = Vue.resource(root);

    Vue.http.interceptors.push((request, next) => {
      // needed in order to not break the tests.
      if ($.rails) {
        request.headers['X-CSRF-Token'] = $.rails.csrfToken();
      }
      next();
    });
  }

  all() {
    return this.environments.get();
  }
}

window.EnvironmentsService = EnvironmentsService;