src/login.ts
constructor(conf: { endpoint?: string; })
|
Public login |
login(username: string, password: string)
|
Returns:
void
|
Protected client |
client: |
Default value: axios
|
Request Client |
Protected endpoint |
endpoint: |
Default value: DEFAULT_ENDPOINT
|
Shifter API Endpoint |
import axios, { AxiosInstance } from 'axios';
import { DEFAULT_ENDPOINT } from './client';
export class Login {
/**
* Request Client
*/
protected readonly client: AxiosInstance = axios;
/**
* Shifter API Endpoint
*/
protected readonly endpoint: string = DEFAULT_ENDPOINT;
constructor(conf?: { endpoint?: string }) {
if (conf && conf.endpoint) this.endpoint = conf.endpoint;
}
public async login(username: string, password: string) {
const result = await this.client.post(`${this.endpoint}/login`, {
username,
password,
});
return result.data;
}
}