@commarket/rewardhub
TypeScript icon, indicating that this package has built-in type declarations

1.0.19 • Public • Published

LoyaltyPlus Library

Installation

To install the @commarket/rewardhub package, you can use npm or yarn:

Using npm

npm install @commarket/rewardhub

Using yarn

yarn add @commarket/rewardhub

Methods

configureAPI Method

The configureAPI method is responsible for setting up and configuring an Axios instance to interact with a rewardhub API. This method handles the following tasks:

  1. Resolves the base URL for the API based on the provided environment.
  2. Sets a timeout for API requests.
  3. Configures request and response interceptors to log requests and responses.
  4. Handles token creation and renewal for authorization.
  5. Set default response language

Usage

Importing the Method

First, import the configureAPI method and the rewardhubApi instance from the module: const apiOptions: ApiOptions = { environment: EnvironmentEnum.PRD, clientId: 'your-client-id', clientSecret: 'your-client-secret', timeout: 60000, //DEFAULT 6000 verbose: false //DEFAULT false language: 'pt-br' //DEFAULT en-us };

configureAPI(apiOptions).then(() => { // Now you can use the configured rewardhubApi instance to make requests rewardhubApi.get('/endpoint') .then(response => { console.log(response.data); }) .catch(error => { console.error('API call error:', error); }); });


For more detailed documentation, please refer to the official [LoyaltyPlus Documentation](https://example.com/docs).

Dependents (0)

Package Sidebar

Install

npm i @commarket/rewardhub

Weekly Downloads

27

Version

1.0.19

License

MIT

Unpacked Size

148 kB

Total Files

257

Last publish

Collaborators

  • fecrodrigues
  • jadsonmoreira