Skip to content
Snippets Groups Projects
Select Git revision
  • 5e579e6874c2e92201e11c2a4fee1e82df7ef1b1
  • develop default protected
  • met-opti-big-data
  • geocontrib-nuxt3
  • redmine-issues/25708
  • 5.4.X
  • 5.5.X
  • redmine-issues/21034
  • license
  • 5.3.X
  • 5.2.X
  • 5.0.X
  • 4.2.X
  • 5.1.X
  • main
  • 3.3.x
  • 2.3.x protected
  • 3.0.X
  • master protected
  • migration-openlayers
  • 6.5.0 protected
  • 6.4.5-rc9 protected
  • 6.4.5-rc8 protected
  • 6.4.5-rc7 protected
  • 6.4.5-rc6 protected
  • 6.4.5-rc5 protected
  • 6.4.5-rc4 protected
  • 6.4.5-rc3 protected
  • 6.4.5-rc1 protected
  • 6.4.5-rc2 protected
  • 6.4.4 protected
  • 6.4.4-rc4 protected
  • 6.4.4-rc3 protected
  • 6.4.4-rc2 protected
  • 6.4.4-rc1 protected
  • 6.4.3 protected
  • 6.4.2 protected
  • 6.4.2-rc1 protected
  • 6.4.1 protected
  • 6.4.1-rc1 protected
40 results

axios-client.js

Blame
  • florent's avatar
    Florent Lavelle authored
    3132bb36
    History
    axios-client.js 836 B
    import axios from 'axios';
    
    axios.defaults.withCredentials = true;
    
    // Add a request interceptor
    axios.interceptors.request.use(function (config) {
    
      config.headers['X-CSRFToken'] = (name => {
        const re = new RegExp(name + '=([^;]+)');
        const value = re.exec(document.cookie);
        return (value != null) ? unescape(value[1]) : null;
      })('csrftoken');
    
      return config;
    
    }, function (error) {
      return Promise.reject(error);
    });
    
    // Add a response interceptor
    axios.interceptors.response.use(function (response) {
    
      response.headers['X-CSRFToken'] = (name => {
        const re = new RegExp(name + '=([^;]+)');
        const value = re.exec(document.cookie);
        return (value != null) ? unescape(value[1]) : null;
      })('csrftoken');
    
      return response;
    
    }, function (error) {
      return Promise.reject(error);
    });
    
    export default axios;