{"id":16321578,"url":"https://github.com/joselion/rxjs-axios","last_synced_at":"2025-03-20T22:31:16.165Z","repository":{"id":62981668,"uuid":"562547634","full_name":"JoseLion/rxjs-axios","owner":"JoseLion","description":"A complete Axios wrapper that uses RxJS observables instead of promises","archived":false,"fork":false,"pushed_at":"2024-06-23T08:32:32.000Z","size":5140,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T15:11:51.403Z","etag":null,"topics":["ajax","axios","http","observable","reactive","request","rxjs","rxjs-observable"],"latest_commit_sha":null,"homepage":"https://joselion.github.io/rxjs-axios/","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/JoseLion.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":"2022-11-06T17:32:34.000Z","updated_at":"2025-03-02T13:56:35.000Z","dependencies_parsed_at":"2023-11-25T07:22:34.836Z","dependency_job_id":"7c28d55a-9dde-4e25-9208-8e27f42a9db6","html_url":"https://github.com/JoseLion/rxjs-axios","commit_stats":{"total_commits":23,"total_committers":1,"mean_commits":23.0,"dds":0.0,"last_synced_commit":"ad000de6aac820e75188f64af1271a8f6867a099"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoseLion%2Frxjs-axios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoseLion%2Frxjs-axios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoseLion%2Frxjs-axios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoseLion%2Frxjs-axios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JoseLion","download_url":"https://codeload.github.com/JoseLion/rxjs-axios/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244085009,"owners_count":20395523,"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":["ajax","axios","http","observable","reactive","request","rxjs","rxjs-observable"],"created_at":"2024-10-10T22:48:15.225Z","updated_at":"2025-03-20T22:31:15.745Z","avatar_url":"https://github.com/JoseLion.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/JoseLion/rxjs-axios/actions/workflows/ci.yml/badge.svg)](https://github.com/JoseLion/rxjs-axios/actions/workflows/ci.yml)\n[![CodeQL](https://github.com/JoseLion/rxjs-axios/actions/workflows/codeql.yml/badge.svg)](https://github.com/JoseLion/rxjs-axios/actions/workflows/codeql.yml)\n[![Pages](https://github.com/JoseLion/rxjs-axios/actions/workflows/pages.yml/badge.svg)](https://github.com/JoseLion/rxjs-axios/actions/workflows/pages.yml)\n[![Release](https://github.com/JoseLion/rxjs-axios/actions/workflows/release.yml/badge.svg)](https://github.com/JoseLion/rxjs-axios/actions/workflows/release.yml)\n[![NPM version](https://img.shields.io/npm/v/rxjs-axios?logo=npm)](https://www.npmjs.com/package/rxjs-axios)\n[![NPM bundle size](https://img.shields.io/bundlephobia/min/rxjs-axios)](https://www.npmjs.com/package/rxjs-axios)\n[![NPM downloads](https://img.shields.io/npm/dm/rxjs-axios)](https://www.npmjs.com/package/rxjs-axios)\n[![NPM license](https://img.shields.io/npm/l/rxjs-axios)](https://github.com/JoseLion/rxjs-axios/blob/main/LICENSE)\n[![GitHub Release Date](https://img.shields.io/github/release-date/JoseLion/rxjs-axios)](https://github.com/JoseLion/rxjs-axios/releases)\n[![Known Vulnerabilities](https://snyk.io/test/github/JoseLion/rxjs-axios/badge.svg)](https://snyk.io/test/github/JoseLion/rxjs-axios)\n\n# rxjs-axios\nA complete Axios wrapper that uses RxJS observables instead of promises. Same Axios API, but anything that used to return a `Promise\u003cT\u003e` will now return an `Observable\u003cT\u003e` instead.\n\n## Overview\nEven though there are a few options out there for Axios wrappers converting its promise-based methods to observables, this library offers a few extra features that make it different:\n\n- Based on Axios **v1.0.0** and forward.\n- TypeScript first oriented.\n  - Written 100% in TypeScript; everything has type definitions.\n  - All Axios types are re-exported, so you can import everything from `rxjs-axios`.\n  - Methods no longer default their type to `any`. Instead, they default to `unknown`, which not only makes things safer but also forces you to add better types to your code.\n- Unsubscribing cancels the request.\n  - Cancellation happens on the observable teardown logic, with no mutation or workarounds.\n  - Uses [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) instead of Axios deprecated `CancelToken`.\n- Seamless usage; works just like Axios.\n  - Besides the Observables, you won't feel any difference with Axios API.\n  - All Axios methods are provided. Other libraries only provide the most commonly used methods (e.g., `get`, `post`, `put`, etc.), while rxjs-axios provide everything available in the Axios instance, like `request(..)`, all form-related methods (e.g., `postForm(..)`, `toFormData(..)`, `formToJSON(..)`, etc.), `isAxiosError(..)`, `defaults`, `interceptors`.\n- Fully tested.\n  - Ensure compatibility around NodeJS, Axios, and RxJS versions.\n  - Safer upgrades, no unexpected surprises.\n\n## Versions Compatibility\n\n- **NodeJS:** \u003e=16\n- **Axios:** \u003e=1.0.0\n- **RxJS:** \u003e=5.5.12\n\n## Install\nThis library has `axios` and `rxjs` as required peer dependencies, so don't forget to add them too.\n\nWith NPM:\n```\nnpm i rxjs-axios axios rxjs\n```\n\nWith Yarn:\n```\nyarn add rxjs-axios axios rxjs\n```\n\n## Usage\nYou can use `rxjs-axios` the same way as you would do with Axios. The only difference is that request will result in an `Observable\u003cAxiosResponse\u003cT\u003e\u003e`, so you'll have to subscribe to the observable to get the response. If you're using TypeScript, remember to add a type to the method's generic 😉.\n\nSimple example:\n```ts\nimport { axios } from \"rxjs-axios\";\nimport { map } from \"rxjs\"\n\naxios.get\u003cUser[]\u003e(\"/api/users\")\n  .pipe(map(({ data }) =\u003e data))\n  .subscribe(users =\u003e {\n    // do anything with users array\n  });\n```\n\nThis becomes particularly cleaner on ReactJS, as you can unsubscribe on the `useEffect(..)` clean-up callback:\n```tsx\nimport { ReactElement, useEffect, useState } from \"react\";\nimport { axios } from \"rxjs-axios\";\nimport { finalize, map } from \"rxjs\"\n\nfunction UsersScreen(): ReactElement {\n  const [pending, setPending] = useState(false);\n  const [users, setUsers] = useState\u003cUser[]\u003e([]);\n\n  useEffect(() =\u003e {\n    setPending(true);\n\n    const subscription = axios.get\u003cUser[]\u003e(\"/api/users\")\n      .pipe(\n        map(({ data }) =\u003e data),\n        finalize(() =\u003e setPending(false)),\n      )\n      .subscribe(setUsers);\n\n    // The request will be canceled if the component is unmounted and the\n    // subscription was not yet complete\n    return () =\u003e subscription.unsubscribe();\n  }, []);\n\n  return (\n    \u003cDataTable\n      pending={pending}\n      data={users}\n      // ...rest of DataTable props\n    /\u003e\n  )\n}\n```\n\n## Something's missing?\n\nSuggestions are always welcome! Please create an [issue](https://github.com/JoseLion/rxjs-axios/issues/new) describing the request, feature, or bug. We'll try to look into it as soon as possible 🙂\n\n## Contributions\n\nContributions are very welcome! To do so, please fork this repository and open a Pull Request to the `main` branch.\n\n## License\n\n[MIT License](https://github.com/JoseLion/rxjs-axios/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoselion%2Frxjs-axios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoselion%2Frxjs-axios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoselion%2Frxjs-axios/lists"}