@irohalab/mira-bangumi-provider-sdk
v5.0.0
Published
An SDK for mira-bangumi-provider API with axios
Downloads
10
Readme
mira-bangumi-provider-sdk
A typescript sdk for mira-bangumi-provider API.
Install
Install from npm:
$ npm install @irohalab/mira-bangumi-provider-sdk --save
Install dependencies:
$ npm install axios tslib typescript --save-dev
Usage
All API method are defined in a class DefaultApi
, you can either create an instance using its constructor or using a factory method
Both way need a Configuration instance as parameter. You usually need to provide a basePath, apiKey or accessKey based on your server
Here are three examples:
Using constructor to create a new instance:
import { Configuration, DefaultApi } from '@irohalab/mira-bangumi-provider-sdk';
export class MyAppClient {
private _apiInstance: DefaultApi;
constructor() {
const config = new Configuration({basePath: 'http://localhost:8085'});
this._apiInstance = new DefaultApi(config);
}
public async getJobList(status: string): Promise<Job[]> {
try {
const resp = await this._apiInstance.listJobs(status, 0, 10);
return resp.data.data as Job[];
} catch (ex) {
return null;
}
}
}
Using factory method
import { DefaultApiFactory, Configuration } from '@irohalab/mira-bangumi-provider-sdk';
async function getJobList(status: string): Promise<Job[]> {
try {
const resp = await DefaultApiFactory(new Configuration({basePath: 'http://localhost:8085'})).listJobs(status, 0, 10);
return resp.data.data as Job[];
} catch (ex) {
return null;
}
}