Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 214 | Rev 1075 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 214 Rev 215
Línea 24... Línea 24...
24
axios.all = Axios.all;
24
axios.all = Axios.all;
25
axios.spread = Axios.spread;
25
axios.spread = Axios.spread;
26
axios.upload = (url,data) => {
26
axios.upload = (url,data) => {
27
  return axios.post(url,createFormData(data),{
27
  return axios.post(url,createFormData(data),{
28
    headers: {
28
    headers: {
29
              'Content-Type': 'multipart/form-data'
29
      'Content-Type': 'multipart/form-data'
30
        }
30
    }
31
  });
31
  });
32
}
32
}
33
axios.interceptors.request.use(
33
axios.interceptors.request.use(
34
  async (config) => {
34
  async (config) => {
35
    if (['post', 'put', 'delete'].includes(config.method)) {
35
    if (['post', 'put', 'delete'].includes(config.method)) {
36
      const csrf = await axios.get('/csrf');
36
      const csrf = await axios.get('/csrf');
37
      if(csrf.data.success){
37
      if(csrf.data.success){
38
        config.headers['X-CSRF-TOKEN'] = csrf.data.data
38
        config.headers['X-CSRF-TOKEN'] = csrf.data.data
39
      }
39
      }
40
      console.log('>>: csrf > ', csrf);
-
 
41
    }
40
    }
42
    return config;
41
    return config;
43
  },
42
  },
44
  (error) => {
43
  (error) => {
45
    return Promise.reject(error);
44
    return Promise.reject(error);