0.6.0 • Published 1 year ago

@interweb/fetch-api-client v0.6.0

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
1 year ago

@interweb/fetch-api-client

@interweb/fetch-api-client is a lightweight and flexible HTTP client for interacting with RESTful APIs in Node.js or the Browser. It supports common HTTP methods such as GET, POST, PUT, PATCH, and DELETE, with customizable options for headers, query parameters, and timeouts.

install

npm install @interweb/fetch-api-client

Usage

Here's an example of how to use @interweb/fetch-api-client:

import { APIClient, APIClientOptions } from '@interweb/fetch-api-client';

const options: APIClientOptions = {
  restEndpoint: 'http://localhost:8001/api'
};

const client = new APIClient(options);

// GET request
client.get('/endpoint')
  .then(response => console.log(response))
  .catch(error => console.error(error));

// GET request with query params
client.get('/endpoint', { search: 'value' })
  .then(response => console.log(response))
  .catch(error => console.error(error));

// POST request with JSON body
client.post('/endpoint', null, { key: 'value' })
  .then(response => console.log(response))
  .catch(error => console.error(error));
0.6.0

1 year ago

0.5.1

1 year ago

0.5.0

1 year ago

0.4.1

1 year ago