<commit_before>import Promise from 'bluebird'
import axios from 'axios'
import _ from 'lodash'
import { pullToken, logout } from './Auth'
import { toast } from 'react-toastify'
import * as licensing from './Auth/licensing'

const defaultOptions = {
  timeout: 2000
}

const createClient = (clientOptions, { toastErrors, addInterceptor }) => {
  const client = axios.create({
    ...defaultOptions,
    ...clientOptions
  })

  client.interceptors.response.use(
    response => response,
    error => {
      const wrappedError = _.get(error, 'response.data')
      const errorCode = _.get(wrappedError, 'errorCode')
      if (errorCode) {
        if (errorCode === 'BP_0005') {
          return logout()
        }
        return Promise.reject(wrappedError)
      } else {
        return Promise.reject(error)
      }
    }
  )<commit_msg>fix(admin-ui): on invalid token, logout user<commit_after>import Promise from 'bluebird'
import axios from 'axios'
import _ from 'lodash'
import { pullToken, logout } from './Auth'
import { toast } from 'react-toastify'
import * as licensing from './Auth/licensing'

const defaultOptions = {
  timeout: 2000
}

const createClient = (clientOptions, { toastErrors, addInterceptor }) => {
  const client = axios.create({
    ...defaultOptions,
    ...clientOptions
  })

  client.interceptors.response.use(
    response => response,
    error => {
      const wrappedError = _.get(error, 'response.data')
      const errorCode = _.get(wrappedError, 'errorCode')
      if (errorCode) {
        if (['BP_0005', 'BP_0041'].includes(errorCode)) {
          return logout()
        }
        return Promise.reject(wrappedError)
      } else {
        return Promise.reject(error)
      }
    }
  )
{'fraction_non_alphanumeric': 0.1261574074074074, 'fraction_numerical': 0.011574074074074073, 'mean_word_length': 2.9029345372460496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3071416', 'n_tokens_mistral': 539, 'n_tokens_neox': 513, 'n_words': 131}