@sarpere/uxios
TypeScript icon, indicating that this package has built-in type declarations

2.0.5 • Public • Published

Uxios

Promise based HTTP client for the browser and node.js. It Allows to use http request more clear, readable and fast.

Installing

Using npm:

$ npm install --registry {verdaccioUrl} uxios

Using yarn:

$ yarn add --registry {verdaccioUrl} uxios

Usage

To initialize model

import Uxios from "Uxios";
class  apiModel  extends  Uxios {
	constructor(){
	 super({ axiosConfig: { "api-url" , "refresh-token-url" } })
	}
}

Javascript Usage

class CameraService extends apiModel {
  constructor() {
    super();
    this.Prefix('Cameras');
  }
  /**
   * @description Get Camera
   * @param Id
   * @returns Camera
   */
  Camera(Id) {
    return this.PrefixId(Id).Get().Save();
  }
}

Typescript Usage

class CameraService extends apiModel {
  constructor() {
    super();
    this.Prefix('Cameras');
  }
  /**
   * @description Get Camera
   * @param  {CameraTypes.CameraId}  Id
   * @returns Camera
   */
  Camera(Id: CameraTypes.CameraId) {
    return this.PrefixId(Id).Get().Save<CameraTypes.Camera>();
  }
}

Typescript Refresh Token Usage

// resolveToken is required!
const resolveToken = (loginResponse: ApiResponse<{ access_token: string }>) => {
  return loginResponse.Data.access_token;
};
class udfModel extends Uxios {
  constructor() {
    super({ axiosConfig: { baseURL: 'apiurl', refreshTokenUrl: '/Token', resolveToken } });
  }
}

Readme

Keywords

Package Sidebar

Install

npm i @sarpere/uxios

Weekly Downloads

0

Version

2.0.5

License

ISC

Unpacked Size

24.9 kB

Total Files

12

Last publish

Collaborators

  • sarpere