https://github.com/ericadamski/rx-get
⛽ An observable wrapper around nodes http(s).get
https://github.com/ericadamski/rx-get
http https node nodejs observable rxjs rxjs6
Last synced: 9 months ago
JSON representation
⛽ An observable wrapper around nodes http(s).get
- Host: GitHub
- URL: https://github.com/ericadamski/rx-get
- Owner: ericadamski
- Created: 2018-06-14T14:07:34.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-27T12:15:54.000Z (over 7 years ago)
- Last Synced: 2025-01-06T09:45:37.529Z (about 1 year ago)
- Topics: http, https, node, nodejs, observable, rxjs, rxjs6
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/rx-get
- Size: 53.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rx-get
[](https://github.com/ngryman/badge-size)
[](https://circleci.com/gh/ericadamski/rx-get)
[](https://github.com/prettier/prettier)
⛽️ An observable wrapper for nodes http.get
## Install
`yarn add rx-get`
or
`npm install rx-get`
## Usage
```javascript
const get = require('rx-get');
const token = 'your_github_token';
// Simple GET request
get('https://api.github.com/emojis', {
headers: {
'user-agent': 'rx-get/1.0 (+https://github.com/ericadamski/rx-get)',
},
}).subscribe({
next({ status, json, text }) {
console.log(status);
console.log(json());
},
});
// GraphQL POST request
get('https://api.github.com/graphql', {
method: 'POST',
headers: {
'content-type': 'application/json',
authorization: `Bearer ${token}`,
},
body: JSON.stringify({
query: /* GraphQL */ `
{
user(login: "ericadamski") {
repositories(last: 5) {
nodes {
name
}
}
}
}
`,
}),
}).subscribe({
next(response) {
console.log(response.json());
},
});
```