xeta
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

xeta

CircleCI NPM Downloads node License MIT

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

Dependencies (2)

Dev Dependencies (32)

Package Sidebar

Install

npm i xeta

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

161 kB

Total Files

38

Last publish

Collaborators

  • nivrith