0.4.12 • Published 7 months ago

@coloco/api-client-svelte v0.4.12

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

@coloco/api-client-svelte

A client for interacting with Coloco APIs.

Installation

npm install @coloco/api-client-svelte

Usage

import { ApiClient } from '@coloco/api-client-svelte';

// Create an API client instance
const apiClient = new ApiClient({
  baseURL: 'https://api.example.com',
  timeout: 5000,
  headers: {
    'X-API-Key': 'your-api-key',
  },
});

// Make a GET request
const user = await apiClient.get('/users/123');

// Make a POST request
const newUser = await apiClient.post('/users', {
  name: 'John Doe',
  email: 'john@example.com',
});

// Make a PUT request
const updatedUser = await apiClient.put('/users/123', {
  name: 'Jane Doe',
});

// Make a DELETE request
await apiClient.delete('/users/123');

API

ApiClient

The main API client class.

Constructor

constructor(options: ApiClientOptions)
  • options.baseURL: The base URL for the API
  • options.timeout: The request timeout in milliseconds (default: 10000)
  • options.headers: Additional headers to include in requests

Methods

get<T>(url: string, config?: AxiosRequestConfig): Promise<T>

Make a GET request to the API.

post<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>

Make a POST request to the API.

put<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>

Make a PUT request to the API.

delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>

Make a DELETE request to the API.

License

MIT

0.4.12

7 months ago

0.4.11

7 months ago

0.4.10

8 months ago

0.4.9

8 months ago

0.4.8

8 months ago

0.4.7

8 months ago

0.4.6

8 months ago

0.4.5

8 months ago

0.4.4

8 months ago

0.4.3

8 months ago

0.4.1

8 months ago

0.4.0

8 months ago

0.3.0

8 months ago

0.2.7

8 months ago

0.2.6

8 months ago

0.2.5

8 months ago

0.2.4

8 months ago

0.2.3

8 months ago

0.2.2

8 months ago

0.2.1

8 months ago

0.2.0

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago