{"id":15413134,"url":"https://github.com/vesparny/rxhr","last_synced_at":"2025-04-19T09:51:01.885Z","repository":{"id":66104146,"uuid":"91330877","full_name":"vesparny/rxhr","owner":"vesparny","description":"Tiny Observable based HTTP client for browsers","archived":false,"fork":false,"pushed_at":"2017-06-07T18:56:45.000Z","size":101,"stargazers_count":15,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T19:44:30.950Z","etag":null,"topics":["client","http","reactive","rxjs","xhr"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/vesparny.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-05-15T11:38:03.000Z","updated_at":"2022-07-28T14:05:21.000Z","dependencies_parsed_at":"2023-06-10T03:45:36.963Z","dependency_job_id":null,"html_url":"https://github.com/vesparny/rxhr","commit_stats":{"total_commits":10,"total_committers":2,"mean_commits":5.0,"dds":0.09999999999999998,"last_synced_commit":"fa8d30c95927912499cf54b46ec23ca05d66829b"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vesparny%2Frxhr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vesparny%2Frxhr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vesparny%2Frxhr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vesparny%2Frxhr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vesparny","download_url":"https://codeload.github.com/vesparny/rxhr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248732484,"owners_count":21152852,"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":["client","http","reactive","rxjs","xhr"],"created_at":"2024-10-01T16:55:35.313Z","updated_at":"2025-04-19T09:51:01.868Z","avatar_url":"https://github.com/vesparny.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rxhr\n\u003e A tiny Observable based HTTP client\n\n[![Travis](https://img.shields.io/travis/vesparny/rxhr.svg)](https://travis-ci.org/vesparny/rxhr)\n[![Code Coverage](https://img.shields.io/codecov/c/github/vesparny/rxhr.svg?style=flat-square)](https://codecov.io/github/vesparny/rxhr)\n[![David](https://img.shields.io/david/vesparny/rxhr.svg)](https://david-dm.org/vesparny/rxhr)\n[![npm](https://img.shields.io/npm/v/rxhr.svg)](https://www.npmjs.com/package/rxhr)\n[![npm](https://img.shields.io/npm/dm/rxhr.svg)](https://npm-stat.com/charts.html?package=rxhr\u0026from=2017-05-19)\n[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)\n[![MIT License](https://img.shields.io/npm/l/rxhr.svg?style=flat-square)](https://github.com/vesparny/rxhr/blob/master/LICENSE)\n\nThe current size of `rxhr/dist/rxhr.umd.min.js` is:\n\n[![gzip size](http://img.badgesize.io/https://unpkg.com/rxhr/dist/rxhr.umd.min.js?compression=gzip\u0026label=gzip%20size\u0026style=flat-square)](https://unpkg.com/rxhr/dist/)\n\n## Install\n\nThis project uses [node](http://nodejs.org) and [npm](https://npmjs.com). Go check them out if you don't have them locally installed.\n\n```sh\n$ npm i rxhr\n```\n\nThen with a module bundler like [rollup](http://rollupjs.org/) or [webpack](https://webpack.js.org/), use as you would anything else:\n\n```javascript\n// using ES6 modules\nimport rxhr from 'rxhr'\n\n// using CommonJS modules\nvar rxhr = require('rxhr')\n```\n\nThe [UMD](https://github.com/umdjs/umd) build is also available on [unpkg](https://unpkg.com):\n\n```html\n\u003cscript src=\"https://unpkg.com/rxhr/dist/rxhr.umd.js\"\u003e\u003c/script\u003e\n```\n\nYou can find the library on `window.rhxr`.\n\n## Usage\n\n```js\nimport rxhr from 'rxhr'\n\nconst req$ = rxhr({\n  method: 'get',\n  responseType: 'json',\n  url: 'https://jsonplaceholder.typicode.com/posts'\n})\n.subscribe(\n  res =\u003e res.json().forEach(e =\u003e console.log(e.title)),\n  err =\u003e console.log(err),\n  () =\u003e console.log('completed')\n)\n\n// abort request\nreq$.unsubscribe()\n```\n\nIt's easy to combine with rxjs\n\n```js\nconst req$ = rxhr({\n  method: 'get',\n  responseType: 'json',\n  url: 'https://jsonplaceholder.typicode.com/posts'\n})\n\nconst sub$ = Rx.Observable\n.timer(0, 1000)\n.switchMap(() =\u003e Rx.Observable.from(req$))\n.map(res =\u003e res.json())\n.subscribe(\n  res =\u003e console.log(res.length),\n  err =\u003e console.log('err', err),\n  () =\u003e console.log('completed')\n)\n```\n\nIt supports blob request type\n\n```js\nconst req$ = rxhr({\n  method: 'get',\n  responseType: 'blob',\n  url: 'https://avatars2.githubusercontent.com/u/82070?v=3\u0026s=460'\n})\n\nconst sub$ = Rx.Observable\n.timer(0, 1000)\n.take(3)\n.switchMap(() =\u003e Rx.Observable.from(req$))\n.map(res =\u003e res.blob())\n.subscribe(\n  blob =\u003e {\n    const fr = new FileReader();\n    fr.onload = function(e) {\n      const img = new Image(); // width, height values are optional params\n      img.src = e.target.result\n      document.body.appendChild(img)\n    }\n    fr.readAsDataURL(blob);\n  },\n  err =\u003e console.log('err', err),\n  () =\u003e console.log('completed')\n)\n```\n\n## Tests\n\n```sh\n$ npm run test\n```\n\n[MIT License](LICENSE.md) © [Alessandro Arnodo](https://alessandro.arnodo.net/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvesparny%2Frxhr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvesparny%2Frxhr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvesparny%2Frxhr/lists"}