https://github.com/runfaj/gretchen-fetch
Making "fetch" happen!
https://github.com/runfaj/gretchen-fetch
Last synced: 4 months ago
JSON representation
Making "fetch" happen!
- Host: GitHub
- URL: https://github.com/runfaj/gretchen-fetch
- Owner: runfaj
- License: gpl-3.0
- Created: 2019-12-21T03:40:06.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-21T04:19:27.000Z (over 6 years ago)
- Last Synced: 2025-09-14T18:49:56.401Z (9 months ago)
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gretchen-fetch
Making "fetch" happen!
This fetch library is _so fetch_! It would make Gretchen proud.
## What is this?
A fetching library that can be used in any javascript-based application, whether that is client side or server side. Included in this fetching library is 3 ways to fetch:
1. Promise-based (regular promise, or async/await)
2. Callback-based (but why would you want to?)
3. Class-based (e.g. new Gretch())
## Installing and Importing
Install:
```
npm install gretchen-fetch
or
yarn gretchen-fetch
```
Importing:
```
import Gretch from 'gretchen-fetch';
or
const Gretch = require('gretchen-fetch');
```
## Usage
Promise-based
```
const somePromise = Gretch.get('', { ...queryParams });
or
const results = await Gretch.get('', { ...queryParams }, function(results) {});
```
Class-based
```
const gretchen = new Gretch();
gretchen.makeFetchHappen(options);
```
## The nitty-gritty
There are several static methods built for you. Each follow the pattern of the following for parameters:
```
Gretch.method(url, params/data, callback, options)
```
- Gretch.get:
- Gretch.post:
- Gretch.put:
- Gretch.delete:
- Gretch.patch:
- Gretch.options:
- Gretch.head:
Alternately, you can use the raw request method to customize to your liking:
```
Gretch.fetch({
method:
url: '',
params: { "key": "value" },
data: ,
callback: (results)=>{},
headers: { "name": "value" },
timeout: ,
responseType: ,
.......?
});
```