TypeScript Client for Cloudesire API
You can find the TypeScript clients on our NPM Repository:
https://nexus.cloudesire.com/repository/cloudesire-npm-public/
Requires axios HTTP client (version
0.27.2
)
Installation
Install the required packages, for example:
npm install @cloudesire/backend-users-api @cloudesire/backend-billing-api
Usage
import axios, { AxiosResponse } from 'axios';
import { Configuration, LoginApi } from '@cloudesire/backend-users-api';
import { SubscriptionApi, SubscriptionDTO } from '@cloudesire/backend-billing-api';
const url = '<cloudesire_api_url>';
const username = '<customer_username>';
const password = '<customer_password>';
// 1. Login to get the auth token
const loginResponse: AxiosResponse<string> = await new LoginApi(
new Configuration({ username, password }),
url,
).login({ expire: true });
const authToken = loginResponse.data;
const axiosInstance = axios.create({
headers: {
'CMW-Auth-Token': authToken,
},
});
// 2. Fetch customer's subscriptions
const response: AxiosResponse<SubscriptionDTO[]> = await (new SubscriptionApi(
new Configuration(),
url,
axiosInstance,
)).subscriptionGetAllPaged({ pageSize: 50 });