{"id":22684280,"url":"https://github.com/davguij/rxios","last_synced_at":"2025-04-13T06:37:15.829Z","repository":{"id":27681158,"uuid":"111325810","full_name":"davguij/rxios","owner":"davguij","description":"A RxJS wrapper for axios","archived":false,"fork":false,"pushed_at":"2023-01-06T01:33:11.000Z","size":1623,"stargazers_count":135,"open_issues_count":16,"forks_count":19,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T23:06:21.424Z","etag":null,"topics":["axios","front-end","frontend","http","http-client","nodejs","observable","observables","request","requests","rx","rxjs","rxjs-wrapper","rxjs6","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/rxios","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/davguij.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-19T19:36:55.000Z","updated_at":"2023-08-14T08:44:26.000Z","dependencies_parsed_at":"2023-01-14T07:16:27.369Z","dependency_job_id":null,"html_url":"https://github.com/davguij/rxios","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davguij%2Frxios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davguij%2Frxios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davguij%2Frxios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davguij%2Frxios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davguij","download_url":"https://codeload.github.com/davguij/rxios/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248675337,"owners_count":21143763,"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","front-end","frontend","http","http-client","nodejs","observable","observables","request","requests","rx","rxjs","rxjs-wrapper","rxjs6","typescript"],"created_at":"2024-12-09T21:19:30.306Z","updated_at":"2025-04-13T06:37:15.807Z","avatar_url":"https://github.com/davguij.png","language":"TypeScript","readme":"# Rxios\n\n### A RxJS wrapper for axios\n\n[![npm](https://badgen.net/npm/v/rxios?color=red\u0026icon=npm)]() ![CI](https://github.com/davguij/rxios/workflows/CI/badge.svg) [![bundlephobia](https://badgen.net/bundlephobia/minzip/rxios)]()\n\nRxios makes the awesome [axios](https://github.com/axios/axios) library reactive, so that it's responses are returned as [RxJS](https://github.com/ReactiveX/rxjs) observables.\n\n## Observables? Why?\n\nRegular promises are cool, especially for HTTP requests in async/await functions.\n\nHowever, Observables provide operators like map, forEach, reduce... There are also powerful operators like `retry()` or `replay()`, that are often quite handy.\n\nObservables also excel when we need to perform some kind of manipulation on the received data, or when we need to chain several requests.\n\nLastly, Reactive stuff is what all the cool kids are doing.\n\n## Installation\n\n`npm install axios rxjs rxios`\n\n## Usage\n\nYou can use Rxios by either\n\n**instantiating the class yourself**\n\n```javascript\nimport { Rxios } from 'rxios';\nconst rxios = new Rxios({ /* options here */ })\nconst request = rxios.get(url)...\n```\n\n**importing a \"ready-to-use\" generic instance**\n\n```javascript\nimport { rxios } from 'rxios';\nconst request = rxios.get(url)...\n```\n\nIn any case, please keep in mind that, when importing, `Rxios` refers to the class and `rxios` to the instance.\n\n### Syntax details\n\n```javascript\nconst { Rxios } = require('rxios');\n// or import { Rxios } from 'rxios';\n\nconst http = new Rxios({\n  // all regular axios request configuration options are valid here\n  // check https://github.com/axios/axios#request-config\n  baseURL: 'https://jsonplaceholder.typicode.com',\n});\n\n// plain GET request\nhttp.get('/posts').subscribe(\n  response =\u003e {\n    console.log(response); // no need to 'response.data'\n  },\n  err =\u003e {\n    console.error(err);\n  }\n);\n\n// GET request with query params\nhttp\n  .get('/posts', { userId: 1 }) // you can pass an object as second param to the get() method\n  .subscribe(\n    response =\u003e {\n      console.log(response); // no need to 'response.data'\n    },\n    err =\u003e {\n      console.error(err);\n    }\n  );\n\n// POST request\nhttp\n  .post('/posts', {\n    // this object will be the payload of the request\n    userId: 1,\n    id: 1,\n    title:\n      'sunt aut facere repellat provident occaecati excepturi optio reprehenderit',\n  })\n  .subscribe(\n    response =\u003e {\n      console.log(response); // again, no need to 'response.data'\n    },\n    err =\u003e {\n      console.error(err);\n    }\n  );\n```\n\n## TypeScript usage\n\nRxios is written in TypeScript, and its typings are provided in this same package.\n\nAlso, just like with axios or with Angular's Http module, response types are accepted by the method, like:\n\n```typescript\nimport { Rxios } from 'rxios';\nconst http = new Rxios();\ninterface MyResponse = {userId: number; id: number; title: string};\nhttp.get\u003cMyResponse[]\u003e('/posts/1')\n  .subscribe(resp: MyResponse[] =\u003e {...});\n```\n\n## Advanced usage\n\nAll Rxios methods always return an Observable, to which we can apply advanced RxJS operations.\n\nFor example, we could make two simultaneous requests and merge their responses as they come, without needing to wait for both to be completed.\n\n```javascript\nimport { Observable } from 'rxjs/Rx';\nimport { Rxios } from 'rxios';\nconst http = new Rxios();\n\nconst firstReq = http.get('/posts/1');\nconst secondReq = http.get('/posts/2');\nfirstReq.merge(secondReq).subscribe(...);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavguij%2Frxios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavguij%2Frxios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavguij%2Frxios/lists"}