Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fourcels/fetch
fetch advance
https://github.com/fourcels/fetch
fetch
Last synced: about 11 hours ago
JSON representation
fetch advance
- Host: GitHub
- URL: https://github.com/fourcels/fetch
- Owner: fourcels
- License: mit
- Created: 2023-09-08T07:48:35.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-14T08:54:24.000Z (about 1 year ago)
- Last Synced: 2024-10-30T16:18:10.660Z (19 days ago)
- Topics: fetch
- Language: TypeScript
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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);
```