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

1.0.56 • Public • Published

LoyaltyPlus Library

Installation

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

Using npm

npm install @commarket/loyaltyplus

Using yarn

yarn add @commarket/loyaltyplus

Methods

configureAPI Method

The configureAPI method is responsible for setting up and configuring an Axios instance to interact with a loyalty 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.

Usage

Importing the Method

First, import the configureAPI method and the loyaltyApi 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 };

configureAPI(apiOptions).then(() => { // Now you can use the configured loyaltyApi instance to make requests loyaltyApi.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).

Readme

Keywords

none

Package Sidebar

Install

npm i @commarket/loyaltyplus

Weekly Downloads

106

Version

1.0.56

License

MIT

Unpacked Size

257 kB

Total Files

395

Last publish

Collaborators

  • jadsonmoreira
  • fecrodrigues