{"id":20388550,"url":"https://github.com/efureev/request-interceptors","last_synced_at":"2026-05-21T16:38:45.488Z","repository":{"id":42392308,"uuid":"350213262","full_name":"efureev/request-interceptors","owner":"efureev","description":"Interceptors for Axios","archived":false,"fork":false,"pushed_at":"2022-11-13T01:43:40.000Z","size":252,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-30T00:32:58.279Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-22T05:03:06.000Z","updated_at":"2022-08-07T09:24:01.000Z","dependencies_parsed_at":"2023-01-21T15:16:44.473Z","dependency_job_id":null,"html_url":"https://github.com/efureev/request-interceptors","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efureev%2Frequest-interceptors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efureev%2Frequest-interceptors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efureev%2Frequest-interceptors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efureev%2Frequest-interceptors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/efureev","download_url":"https://codeload.github.com/efureev/request-interceptors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241763745,"owners_count":20016162,"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:23.607Z","updated_at":"2025-12-02T17:02:09.314Z","avatar_url":"https://github.com/efureev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# interceptors for the Axios\n\n## List of request interceptor\n\n- AuthInterceptor\n\n## List of response interceptor\n\n- WrapperInterceptor\n- ActionInterceptor\n\n### WrapperInterceptor\n\nWraps axios-response to `ResponseWrapper` wrapper. Wraps success and error responses.\n\n### ActionInterceptor\n\nExecute some action by attributes from response.\nActions:\n- Redirect\n- Download file by link\n- Blob download\n\nResponse must have following structure:\n\nFor redirect\n```json\n{\n  \"status\": {\n    \"type\": \"redirect\",\n    \"url\": \"https://google.com\"  \n  }\n}\n```\n\nFor download by url\n```json\n{\n  \"status\": {\n    \"type\": \"download\",\n    \"url\": \"https://google.com/file.pdf\",  \n    \"name\": \"ExampleFile.pdf\"  \n  }\n}\n```\nFor download blob-file\nheaders:\n```json\n{\n  \"Access-Control-Expose-Headers\" : \"Content-Disposition\",\n  \"x-filename\": \"test2.pdf\"\n}\n```\n\nSample for Server side (Laravel Controler):\n```php\nreturn Storage::disk('public')-\u003edownload(\n    $user-\u003eavatar,\n    \"avater.{$ext}\",\n    [\n        'Access-Control-Expose-Headers' =\u003e 'Content-Disposition',\n        'x-filename'                    =\u003e \"test2.{$ext}\",\n    ]\n);\n```\n\n## Basic usage\n\n```js\nimport buildRequest from '@feugene/layer-request'\n\nconst apiHost = process.env.VUE_APP_API_HOST || ''\n\nexport const createRequest = (store, config) =\u003e {\n  const request = buildRequest({ extra: { store } })\n\n  request.manager.addLayer((cm) =\u003e {\n    return cm.new({\n      requestConfig: {\n        headers: {\n          ...(isObject(config.headers) ? config.headers : {}),\n          'X-Requested-With': 'XMLHttpRequest',\n        },\n        baseURL: `${apiHost}/api`,\n      },\n      interceptors: {\n        request: [(config) =\u003e (rConfig) =\u003e {\n          console.info(`\\t🌐 ${rConfig.baseURL}/${rConfig.url}`)\n          return rConfig\n        }],\n        response: [\n          (config) =\u003e (response) =\u003e {\n            console.info(`\\t✅ ${response.request.responseURL}`)\n            return response\n          },\n          Interceptor(),\n          ActionInterceptorBuild({\n            actionAttributeName: 'status',\n          }),\n        ],\n      },\n    })\n  }, 'api')\n\n  return request\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefureev%2Frequest-interceptors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fefureev%2Frequest-interceptors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefureev%2Frequest-interceptors/lists"}