1.9.0 • Published 10 months ago
@coaktion/client-core v1.9.0
Client Core
Client Core is a library helping you to create a client RestFul API.
Installation
npm install @coaktion/client-core
Generate docs
npm run generate-docs
Usage
import {
AxiosClient,
ClientOptionsAxios,
converterPathParamsUrl
} from '@coaktion/client-core';
import { AxiosResponse } from 'axios';
class ApiClient extends AxiosClient {
constructor(clientOptions: ClientOptionsAxios) {
super(clientOptions);
}
async custom(id: string): Promise<AxiosResponse> {
return this.makeRequest(
'GET',
converterPathParamsUrl('/resources/{id}/custom', { id })
);
}
}
const apiClient = new ApiClient('https://api.example.com');
apiClient.search({ query: 'test' }).then((response) => {
console.log(response.data);
});
apiClient.fetch('123').then((response) => {
console.log(response.data);
});
apiClient.create({ name: 'test' }).then((response) => {
console.log(response.data);
});
apiClient.update('123', { name: 'test' }).then((response) => {
console.log(response.data);
});
apiClient.delete('123').then((response) => {
console.log(response.data);
});
apiClient.custom('123').then((response) => {
console.log(response.data);
});
License
Client Core is Copyright.
Author
1.9.0
10 months ago
1.8.1
11 months ago
1.8.3
11 months ago
1.8.0
2 years ago
1.7.2
2 years ago
1.7.1
2 years ago
1.7.0
2 years ago
1.6.0
2 years ago
1.5.5
2 years ago
1.5.4
2 years ago
1.5.3
2 years ago
1.5.2
2 years ago
1.5.1
2 years ago
1.3.3
2 years ago
1.5.0
2 years ago
1.4.1
2 years ago
1.4.0
2 years ago
1.3.2
2 years ago
1.3.1
2 years ago
1.3.0
2 years ago
1.2.0
2 years ago