{"size": 703, "ext": "js", "max_stars_repo_path": "src/module/actions/getAction.js", "max_stars_repo_name": "eFrane/vuex-json-api", "max_stars_repo_stars_event_min_datetime": "2019-09-23T11:28:13.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-28T23:31:36.000Z", "max_issues_repo_path": "src/module/actions/getAction.js", "max_issues_repo_name": "eFrane/vuex-json-api", "max_issues_repo_issues_event_min_datetime": "2019-08-07T17:11:31.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-28T02:01:13.000Z", "max_forks_repo_path": "src/module/actions/getAction.js", "max_forks_repo_name": "eFrane/vuex-json-api", "max_forks_repo_forks_event_min_datetime": "2019-09-19T08:21:31.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-13T17:22:39.000Z"}
{"max_stars_count": 4, "max_issues_count": 174, "max_forks_count": 4, "avg_line_length": 25.1071428571, "max_line_length": 75, "alphanum_fraction": 0.6600284495}
import { processResponseData } from '../helpers/processResponseData'
import { prepareQuery } from '../helpers/prepareQuery'

/**
 * Get a resource
 *
 * @param {ResourcefulApi} api
 * @param {String} moduleName
 * @param {Object|undefined} defaultQuery
 */
export function getAction (api, moduleName, defaultQuery) {
  return new Proxy(() => {}, {
    apply (target, thisArg, [vuexFns, query]) {
      query = prepareQuery(query, defaultQuery)

      vuexFns.commit('startLoading')

      return api[moduleName].get(query).then(response => {
        processResponseData(vuexFns, api, moduleName, response.data, 'get')

        vuexFns.commit('endLoading')

        return response
      })
    }
  })
}
