0.4.12 • Published 9 months ago

@coloco/api-client-svelte v0.4.12

Weekly downloads
-
License
MIT
Repository
github
Last release
9 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

9 months ago

0.4.11

9 months ago

0.4.10

10 months ago

0.4.9

10 months ago

0.4.8

10 months ago

0.4.7

10 months ago

0.4.6

10 months ago

0.4.5

10 months ago

0.4.4

10 months ago

0.4.3

10 months ago

0.4.1

10 months ago

0.4.0

10 months ago

0.3.0

10 months ago

0.2.7

10 months ago

0.2.6

10 months ago

0.2.5

10 months ago

0.2.4

10 months ago

0.2.3

10 months ago

0.2.2

10 months ago

0.2.1

10 months ago

0.2.0

10 months ago

0.1.1

11 months ago

0.1.0

11 months ago