Class

AxiosApi

AxiosApi()

API Requests Hooks. Instance name: axiosApi

Axios is a library that the app uses to communicate with servers. You can modify the process by using AxiosApi.

Constructor

# new AxiosApi()

Example
externalCodeSetup.axiosApi.METHOD_NAME

Methods

# addCustomRequestDecorator(decorator)

Add decorator function to add additional headers in api requests

Parameters:
Name Type Description
decorator function

function which returns modified requests headers

Example

Add axios decorator to modify or overide api requests headers

externalCodeSetup.axiosApi.addCustomRequestDecorator(() => {
 return original => {
   return args => {
     args.headers = {
       ...args.headers,
       "custom-header-key": "custom-header-value"
     };
     return original(args)
       .catch(error => Promise.reject(error))
       .then(response => response);
     };
 }
});

# enableClearCache()

You can use this to enable clearing API cache for each request to ensure the server gives the latest data.

Example
externalCodeSetup.axiosApi.enableClearCache();

# setAchievementsParams(params)

Sets additional params used for fetching achievements that you can display in the achievements sections of your app.

Parameters:
Name Type Description
params Object
Example

Add an "orderby" parameter when fetching achievements API

externalCodeSetup.axiosApi.setAchievementsParams({orderby: "date"});