Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fourcels/fetch

fetch advance
https://github.com/fourcels/fetch

fetch

Last synced: about 11 hours ago
JSON representation

fetch advance

Awesome Lists containing this project

README

        

# fetch advance

## Install

```bash
npm install @fourcels/fetch
```

## Usage

### default fetch

```js
import fetch from "@fourcels/fetch";

const { data } = await fetch.GET("https://dummyjson.com/products", {
limit: 10,
});
console.log(data);
```

### custom fetch

```js
import { Fetch } from "@fourcels/fetch";

const fetcher = new Fetch("https://dummyjson.com", {
authFunc(headers) {
headers.append("Authorization", "Bearer token");
},
handleError(res, data) {
console.log(data);
},
});
const { data } = await fetcher.POST("/products/add", {
title: "BMW Pencil",
});
console.log(data);
```