<commit_before>import Axios from 'axios'
import { Toast } from 'quasar'

/*
* Axios configured for Django REST API
*/

import { camelizeKeys, underscorizeKeys } from '@/services/utils'

const axios = Axios.create({
  xsrfCookieName: 'csrftoken',
  xsrfHeaderName: 'X-CSRFTOKEN',
})

axios.interceptors.request.use(request => {
  request.data = underscorizeKeys(request.data)
  return request
}, (error) => {
  Toast.create.warning('Could not connect to the server') // TODO translate
  return Promise.reject(error)
})

axios.interceptors.response.use(response => {
  response.data = camelizeKeys(response.data)
  return response
}, (error) => {
  if (error.response.status >= 500) {
    Toast.create.warning('Server error') // TODO translate
  }
  else {
    error.data = camelizeKeys(error.data)
  }
  return Promise.reject(error)
})

export default axios<commit_msg>translate axios errors<commit_after>import Axios from 'axios'
import { Toast } from 'quasar'
import i18n from '@/i18n'

/*
* Axios configured for Django REST API
*/

import { camelizeKeys, underscorizeKeys } from '@/services/utils'

const axios = Axios.create({
  xsrfCookieName: 'csrftoken',
  xsrfHeaderName: 'X-CSRFTOKEN',
})

axios.interceptors.request.use(request => {
  request.data = underscorizeKeys(request.data)
  return request
}, (error) => {
  Toast.create.warning(i18n.t('GLOBAL.CONNECTION_INTERRUPTED'))
  return Promise.reject(error)
})

axios.interceptors.response.use(response => {
  response.data = camelizeKeys(response.data)
  return response
}, (error) => {
  if (error.response.status >= 500) {
    Toast.create.warning(i18n.t('GLOBAL.SERVER_ERROR'))
  }
  else {
    error.data = camelizeKeys(error.data)
  }
  return Promise.reject(error)
})

export default axios
{'fraction_non_alphanumeric': 0.1366742596810934, 'fraction_numerical': 0.007972665148063782, 'mean_word_length': 4.456521739130435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '315920', 'n_tokens_mistral': 621, 'n_tokens_neox': 600, 'n_words': 121}