TypeScript client library¶
To use this library first create a .npmrc
file in your repository with the following content:
@enpowerx:registry=https://pkgs.dev.azure.com/enbw/EnPowerX/_packaging/enpxio/npm/registry/
always-auth=true
Then open a shell and run the following commands:
npm install -g vsts-npm-auth
vsts-npm-auth -config .npmrc
npm install @enpowerx/apis
Sample code to list Contracts:
import { ApisEndpoint, NotFoundTenantError } from '@enpowerx/apis';
const apis = new ApisEndpoint(new URL('https://apis.enpowerx.io/'), authToken);
try {
const myContracts = await apis.resources.v1.me.contracts.list();
// ...
} catch (error) {
switch (error.constructor) {
case NotFoundTenantError:
// TODO: Invalid tenant
break;
default:
// TODO: Generic error handling
break;
}
}