import Axios from 'axios'

class RailsRanger {
  constructor() {
    // Add config for hostname
    // Add config for headers
    // Add config for timeout
    // Add config for namespaces
    this.client = Axios.create({})
  }

  post(path, params) {
    return this.client.post(path, params)
  }

  get(path, pathParams, queryParams) {
    let processedPath = path

    pathParams.forEachWithIndex((paramName, paramValue) => {
      processedPath = path.gsub(':' + paramName, paramValue)
    })

    return this.client.get(processedPath, queryParams)
  }
}

import Axios from 'axios'

class RailsRanger {
  constructor(configs = {}) {
    // Falls back to Axios configurations
    this.client = Axios.create(configs)
  }

  post(path, params) {
    return this.client.post(path, params)
  }

  //
  // Usage example:
  // > api.get('/blog_posts/:id', { id: 1, flag: true })
  // Will generate:
  // > /blog_posts/1?flag=true
  //
  get(path, params) {
    let processedPath   = path
    let processedParams = params

    for (let key in params) {
      // Skipping inherited proprieties
      if (!params.hasOwnProperty(key)) { continue }

      processedPath = path.replace(':' + key, params[key])

      // If the key was used in the path, it shouldn't be sent as
      // a query parameter
      delete processedParams[key]
    }

    return this.client.get(processedPath, processedParams)
  }
}

export default RailsRanger


Implement the get method