1.8.0 • Published 5 months ago

@coaktion/client-core v1.8.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Client Core

test workflow stale workflow Release Draft workflow

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

GitHub

1.8.0

5 months ago

1.7.2

6 months ago

1.7.1

6 months ago

1.7.0

6 months ago

1.6.0

6 months ago

1.5.5

6 months ago

1.5.4

6 months ago

1.5.3

6 months ago

1.5.2

7 months ago

1.5.1

7 months ago

1.3.3

9 months ago

1.5.0

8 months ago

1.4.1

8 months ago

1.4.0

9 months ago

1.3.2

12 months ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago