Skip to content

Commit

Permalink
docs: Update Standalone and Multi API examples
Browse files Browse the repository at this point in the history
  • Loading branch information
MattCCC committed Sep 20, 2024
1 parent 8ac18d0 commit 70cea0d
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Managing multiple API endpoints can be complex and time-consuming. `fetchff` sim

Please open an issue for future requests.

## ✔️ Quick Start
## ✔️ Install

[![NPM](https://nodei.co/npm/fetchff.png)](https://npmjs.org/package/fetchff)

Expand All @@ -63,13 +63,13 @@ Using Yarn:
yarn add fetchff
```

###

## ✔️ API

### Standalone usage

`fetchf()` is a functional wrapper for `fetch()`. It seamlessly enhances it with additional settings like the retry mechanism and error handling improvements. The `fetchf()` can be used directly as a function, simplifying the usage and making it easier to integrate with functional programming styles. The `fetchf()` makes requests independently of `createApiFetcher()` settings.
#### `fetchf()`

It is a functional wrapper for `fetch()`. It seamlessly enhances it with additional settings like the retry mechanism and error handling improvements. The `fetchf()` can be used directly as a function, simplifying the usage and making it easier to integrate with functional programming styles. The `fetchf()` makes requests independently of `createApiFetcher()` settings.

#### Example

Expand Down Expand Up @@ -116,7 +116,9 @@ To address these challenges, the `fetchf()` provides several enhancements:

### Multiple API Endpoints

`createApiFetcher()` is a powerful factory function for creating API fetchers with advanced features. It provides a convenient way to configure and manage multiple API endpoints using a declarative approach. This function offers integration with retry mechanisms, error handling improvements, and all the other settings. Unlike traditional methods, `createApiFetcher()` allows you to set up and use API endpoints efficiently with minimal boilerplate code.
#### `createApiFetcher()`

It is a powerful factory function for creating API fetchers with advanced features. It provides a convenient way to configure and manage multiple API endpoints using a declarative approach. This function offers integration with retry mechanisms, error handling improvements, and all the other settings. Unlike traditional methods, `createApiFetcher()` allows you to set up and use API endpoints efficiently with minimal boilerplate code.

#### Example

Expand Down Expand Up @@ -154,7 +156,13 @@ const { data, error } = await api.getUser({
});
```

The `const api` methods and properties are described below:
#### How It Works

The `const api` automatically creates API methods based on the endpoints provided. It also exposes some extra methods and properties.

<details>
<summary><span style="cursor:pointer">Click to expand</span></summary>
<br>

#### `api.myEndpointName(queryParamsOrBodyPayload, urlPathParams, requestConfig)`

Expand Down Expand Up @@ -286,6 +294,8 @@ const { data, error } = await api.request('https://example.com/api/user', {
});
```

</details>

## ✔️ Settings (Request Config)

You can pass the settings:
Expand Down

0 comments on commit 70cea0d

Please sign in to comment.