xeta
v1.0.0
Published
lightweight http client for web and node
Downloads
3
Readme
xeta
Observable based http client for web and node
Highlights
- Written in Typescript
- Works in Browser and Node
- Easy Observable based API
Installation
npm:
$ npm install xeta
yarn:
$ yarn add xeta
Usage
lightweight http client for web and node
const { xeta } = require('xeta');
xeta.get('https://jsonplaceholder.typicode.com/todos/1')
.subscribe((response) => {
// handle success
console.log(response);
},
(error) => {
// handle error
console.error(error)
},
()=>{
// handle completion
console.log('complete');
}
);
// Promise
xeta.get('https://jsonplaceholder.typicode.com/todos/1')
.toPromise()
.then(function (response) {
// handle success
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.finally(function () {
// always executed
});
// async/await
async function getTodo() {
try {
const response = await xeta.get('https://jsonplaceholder.typicode.com/todos/1').toPromise();
console.log(response);
} catch (error) {
console.error(error);
}
}
License
MIT © Nivrith