{"id":16675829,"url":"https://github.com/mpyw/axios-case-converter","last_synced_at":"2025-05-08T21:21:53.095Z","repository":{"id":48978223,"uuid":"103362709","full_name":"mpyw/axios-case-converter","owner":"mpyw","description":"Axios transformer/interceptor that converts snake_case/camelCase","archived":false,"fork":false,"pushed_at":"2024-01-18T11:29:38.000Z","size":107,"stargazers_count":161,"open_issues_count":4,"forks_count":18,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-06T16:15:33.178Z","etag":null,"topics":["axios","camelcase","http-client","javascript","snake-case","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mpyw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-09-13T06:35:09.000Z","updated_at":"2025-04-29T09:04:52.000Z","dependencies_parsed_at":"2024-01-18T12:44:58.275Z","dependency_job_id":"99ef1289-2689-409c-9f10-c89e1ce2274a","html_url":"https://github.com/mpyw/axios-case-converter","commit_stats":{"total_commits":74,"total_committers":9,"mean_commits":8.222222222222221,"dds":0.2432432432432432,"last_synced_commit":"c29875fbb04c3c23dfe0b500c205127ed6da83cb"},"previous_names":["mpyw/axios-interceptor-change-case"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Faxios-case-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Faxios-case-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Faxios-case-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Faxios-case-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpyw","download_url":"https://codeload.github.com/mpyw/axios-case-converter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253150089,"owners_count":21861831,"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":["axios","camelcase","http-client","javascript","snake-case","typescript"],"created_at":"2024-10-12T13:08:04.549Z","updated_at":"2025-05-08T21:21:53.071Z","avatar_url":"https://github.com/mpyw.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# axios-case-converter\n\n[![npm version](https://badge.fury.io/js/axios-case-converter.svg)](https://badge.fury.io/js/axios-case-converter)\n[![Build Status](https://github.com/mpyw/axios-case-converter/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/mpyw/axios-case-converter/actions)\n[![Coverage Status](https://coveralls.io/repos/github/mpyw/axios-case-converter/badge.svg?branch=master)](https://coveralls.io/github/mpyw/axios-case-converter?branch=master)\n\nAxios transformer/interceptor that converts _snake_case/camelCase_\n\n- Converts outgoing `data` `params` object keys into _snake_case_\n- Converts incoming `data` object keys into _camelCase_\n- Converts outgoing `headers` object keys into _Header-Case_\n- Converts incoming `headers` object keys into _camelCase_\n\n## Installing\n\n### NPM\n\n```bash\nnpm install axios-case-converter\n```\n\n\u003e [!IMPORTANT]\n\u003e\n\u003e Axios is a peer dependency of axios-case-converter and must be installed separately.\n\u003e\n\u003e ```bash\n\u003e npm install axios\n\u003e ```\n\n### CDN\n\n```html\n\u003cscript src=\"https://unpkg.com/axios-case-converter@latest/dist/axios-case-converter.min.js\"\u003e\u003c/script\u003e\n```\n\nIt is strongly recommended that you replace `latest` with a fixed version.\n\n## Usage\n\nYou can fully use _camelCase_ in your JavaScript codes.\n\n```js\nimport applyCaseMiddleware from 'axios-case-converter';\nimport axios from 'axios';\n\n(async () =\u003e {\n  const client = applyCaseMiddleware(axios.create());\n  const { data } = await client.post(\n    'https://example.com/api/endpoint',\n    {\n      targetId: 1\n    },\n    {\n      params: { userId: 1 },\n      headers: { userAgent: 'Mozilla' }\n    }\n  );\n\n  console.log(data.actionResult.users[0].screenName);\n})();\n```\n\n## Options\n\n```js\nconst client = applyCaseMiddleware(axios.create(), options);\n```\n\n### `preservedKeys`: `string[] | Function`\n\nDisable transformation when the string matched or satisfied the condition.\n\n```js\nconst options = {\n  preservedKeys: ['preserve_this_key_1', 'preserve_this_key_2']\n};\n```\n\n```js\nconst options = {\n  preservedKeys: (input) =\u003e {\n    return ['preserve_this_key_1', 'preserve_this_key_2'].includes(input);\n  }\n};\n```\n\n### `ignoreHeaders`: `boolean`\n\nDisable HTTP headers transformation.\n\n```js\nconst options = {\n  ignoreHeaders: true\n};\n```\n\n### `ignoreParams`: `boolean`\n\nDisable HTTP URL  parameters transformation.\n\n```js\nconst options = {\n  ignoreParams: true\n};\n```\n\n### `caseFunctions`: `{ snake?: Function, camel?: Function, header?: Function }`\n\nOverride built-in `change-case` functions.\n\n```js\nconst options = {\n  caseFunctions: {\n    camel: (input, options) =\u003e {\n      return (input.charAt(0).toLowerCase() + input.slice(1)).replace(/[-_](.)/g, (match, group1) =\u003e group1.toUpperCase());\n    }\n  }\n};\n```\n\n\n### `caseOptions`: `{ stripRegexp?: RegExp }`\n\nBy default, **`{ stripRegexp: /[^A-Z0-9[\\]]+/gi }`** is used as default `change-case` function options.\nThis preserves `[]` chars in object keys.\nIf you wish keeping original `change-case` behavior, override the options.\n\n```js\nconst options = {\n  caseOptions: {\n    stripRegexp: /[^A-Z0-9]+/gi\n  }\n};\n```\n\n### `caseMiddleware`: `{ requestTransformer?: Function, responseTransformer?: Function, requestInterceptor?: Function }`\n\nTotally override `axios-case-converter` behaviors.\n\n```js\nconst options = {\n  caseMiddleware: {\n    requestInterceptor: (config) =\u003e {\n      // Disable query string transformation\n      return config;\n    }\n  }\n};\n```\n\n###### [Check the tests for more info](test)\n\n## Attention\n\n\u003e [!WARNING]\n\u003e ### `Object` compatibility\n\u003e\n\u003e If you run on **Internet Explorer**, you need polyfill for `Object.prorotypte.entries()`.\n\u003e\n\u003e - [zloirock/core-js: Standard Library](https://github.com/zloirock/core-js)\n\n\u003e [!WARNING]\n\u003e ### `FormData` compatibility\n\u003e\n\u003e If you use `FormData` on **Internet Explorer**, you need polyfill of `FormData.prototype.entries()`.\n\u003e\n\u003e - [jimmywarting/FormData: HTML5 `FormData` polyfill for Browsers.](https://github.com/jimmywarting/FormData)\n\u003e\n\u003e If you use `FormData` on **React Native**, please ignore the following warnings after confirming that polyfill is **impossible**.\n\u003e\n\u003e ```js\n\u003e // RN \u003e= 0.52\n\u003e import { YellowBox } from 'react-native';\n\u003e YellowBox.ignoreWarnings([\n\u003e   'Be careful that FormData cannot be transformed on React Native.'\n\u003e ]);\n\u003e \n\u003e // RN \u003c 0.52\n\u003e console.ignoredYellowBox = [\n\u003e   'Be careful that FormData cannot be transformed on React Native.'\n\u003e ];\n\u003e ```\n\n\u003e [!WARNING]\n\u003e ### `Symbol` compatibility\n\u003e\n\u003e If you use **React Native** for **Android** development, you should use **Symbol** polyfill from `core-js` to avoid bugs with iterators:\n\u003e\n\u003e 1. Create `polyfill.js` in root directory with code:\n\u003e\n\u003e ```js\n\u003e global.Symbol = require('core-js/es6/symbol');\n\u003e require('core-js/fn/symbol/iterator');\n\u003e ```\n\u003e\n\u003e 2. Include `polyfill.js` in entry point of your app (e.g. `app.js`):\n\u003e\n\u003e ```js\n\u003e import { Platform } from 'react-native';\n\u003e\n\u003e // ...\n\u003e\n\u003e if (Platform.OS === 'android') {\n\u003e   require('./polyfill.js');\n\u003e }\n\u003e ```\n\u003e\n\u003e cf. [undefined is not a function(evaluating '_iterator\\[typeof Symbol === \"function\"?Symbol.iterator:\"@@iterator\"\\]()') · Issue #15902 · facebook/react-native](https://github.com/facebook/react-native/issues/15902)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpyw%2Faxios-case-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpyw%2Faxios-case-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpyw%2Faxios-case-converter/lists"}