{"id":20388601,"url":"https://github.com/efureev/request-wrapper","last_synced_at":"2026-05-21T16:38:39.137Z","repository":{"id":90771420,"uuid":"341800318","full_name":"efureev/request-wrapper","owner":"efureev","description":null,"archived":false,"fork":false,"pushed_at":"2021-03-17T12:49:33.000Z","size":44,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-15T09:03:03.159Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/efureev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-24T06:21:04.000Z","updated_at":"2022-03-16T19:19:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"2d5e15a3-2938-449d-a2e6-0946d16361e5","html_url":"https://github.com/efureev/request-wrapper","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efureev%2Frequest-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efureev%2Frequest-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efureev%2Frequest-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efureev%2Frequest-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/efureev","download_url":"https://codeload.github.com/efureev/request-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241940541,"owners_count":20045878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T03:11:47.241Z","updated_at":"2025-12-02T17:02:29.369Z","avatar_url":"https://github.com/efureev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# request-wrapper\n\n## Basic usage\n\nResponse wrapper with no data-key. All response data is in native `response.data` scope.\nIt's used to get content of a response. Example: content of a file. \n```js\nrequest({ responseWrapper: { dataKey: null } })\n.get('download', { params: { disk, path } })\n    .then(response=\u003e{\n      console.log(response.data())\n    })\n```\n\nResponse wrapper with data-key. By default, data-key is `data`.\nIt's used to get data from json response. Example json:\n```json\n{\n  \"data\": {\n    \"id\": 1,\n    \"name\": \"test\"\n  }\n}\n```\n```js\nrequest().get('list')\n.then(response=\u003e{\n  console.log(response.data()\n)})\n```\n\n## Use in package\n\n`\u003cpackage\u003e/request/index.js`:\n\n```js\nconst fmApiPath = process.env.VUE_APP_LFM_PATH || 'file-manager'\n\nconst wrapRequest = axiosInstance =\u003e {\n  return axiosInstance.reconfigure(\n    instance =\u003e {\n      instance.config.baseURL += `/${fmApiPath}`\n      instance.registerRequestInterceptors(LoadingRequestInterceptor)\n      instance.registerResponseInterceptors(LoadingResponseInterceptor, ResponseNoticeInterceptor)\n    }\n  )\n}\n\nconst request = config =\u003e {\n  return wrapRequest(Vue.prototype.$request(config))\n}\n\nexport default request\n```\n\nuse package's request in application\n\n`\u003capp\u003e/request/index.js`:\n\n```js\nimport buildBaseRequest from '@feugene/request'\n\nconst basePath = process.env.VUE_APP_BASE_PATH\n\nconst request = store =\u003e (config = {}) =\u003e {\n  const headers = {\n    ...(isObject(config.headers) ? config.headers : {}),\n  }\n\n  const mergedConfig = {\n    baseURL: basePath,\n    ...config,\n    headers,\n  }\n\n  mergedConfig.store = store\n\n  return buildBaseRequest(mergedConfig)\n}\n\nexport default request\n\n```\n\n`\u003caap\u003e/main.js`\n\n```js\nimport Vue from 'vue'\nimport Vuex from 'vuex'\nimport request from './request'\nVue.use(Vuex)\n\nconst store = new Vuex.Store()\nVue.prototype.$request = request(store)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefureev%2Frequest-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fefureev%2Frequest-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefureev%2Frequest-wrapper/lists"}