import { camelizeKeys, decamelizeKeys } from 'humps'

const DataTransformations = {
  prepareRequest (data, headers) {
    if (headers && headers['Content-Type'] === undefined) {
      headers['Content-Type'] = 'application/json;charset=utf-8'
    }
    return JSON.stringify(this.railsFormat(data))
  },

  prepareResponse (data, _headers) {
    return this.jsFormat(data)
  },

  railsFormat (data) {
    return decamelizeKeys(data)
  },

  jsFormat (data) {
    return camelizeKeys(data)
  }
}

export default DataTransformations

import { camelizeKeys, decamelizeKeys } from 'humps'
import Axios                            from 'axios'

const DataTransformations = {
  prepareRequest (data, headers) {
    const defaultTransformRequest = Axios.defaults.transformRequest[0]
    const railsData               = this.railsFormat(data)

    return defaultTransformRequest(railsData, headers)
  },

  prepareResponse (data, _headers) {
    return this.jsFormat(data)
  },

  railsFormat (data) {
    return decamelizeKeys(data)
  },

  jsFormat (data) {
    return camelizeKeys(data)
  }
}

export default DataTransformations

Change prepareRequest to take advantage of axios transform
Change prepareRequest to take advantage of axios transform
