Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bolajiayodeji/simple-fetch-library
A simple Fetch API library for making HTTP Requests
https://github.com/bolajiayodeji/simple-fetch-library
fetch-api fetching-data-from-server http library
Last synced: about 1 month ago
JSON representation
A simple Fetch API library for making HTTP Requests
- Host: GitHub
- URL: https://github.com/bolajiayodeji/simple-fetch-library
- Owner: BolajiAyodeji
- License: mit
- Created: 2019-04-05T17:23:31.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-11T08:51:57.000Z (over 3 years ago)
- Last Synced: 2024-05-02T01:48:55.534Z (7 months ago)
- Topics: fetch-api, fetching-data-from-server, http, library
- Language: JavaScript
- Homepage: https://bolajiayodeji.github.io/simple-fetch-library/
- Size: 2.21 MB
- Stars: 14
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Getting Started
Download and include the JavaScript file | [full version](https://github.com/BolajiAyodeji/simple-fetch-library/blob/master/dist/simpleFetch.js) | [minified](https://github.com/BolajiAyodeji/simple-fetch-library/blob/master/dist/simpleFetch.min.js) | [ES6 version](https://github.com/BolajiAyodeji/simple-fetch-library/blob/master/src/simpleFetch.js) |
```html
```
```html```
> Create a new simpleFETCH
```js
const http = new simpleFetch;
```# Examples
* GET Request
```js
http.get("https://jsonplaceholder.typicode.com/users")
.then(data => console.log(data))
.catch(err => console.log(err));
```* POST Request
```js
const data = {
"name": "Bolaji Ayodeji",
"username": "bolajiayodeji",
"email": "[email protected]",
"address": {
"street": "Hello world",
"suite": "Hello",
"city": "Lokoja, Kogi",
"zipcode": "xxx-xxx-xxx",
"geo": {
"lat": "29.4572",
"lng": "-164.2990"
}
},
"phone": "+234 8109445504",
"website": "https://bolajiayodeji.com",
"company": {
"name": "PhilanthroLab",
"catchPhrase": "Multi-tiered zero tolerance productivity",
"bs": "transition cutting-edge web services"
}
};http.post("https://jsonplaceholder.typicode.com/users", data)
.then(data => console.log(data))
.catch(err => console.log(err));
```* PUT Request
```js
const data = {
"name": "Bolaji Ayodeji",
"username": "bolajiayodeji",
"email": "[email protected]",
"address": {
"street": "Hello world",
"suite": "Hello",
"city": "Lokoja, Kogi",
"zipcode": "xxx-xxx-xxx",
"geo": {
"lat": "29.4572",
"lng": "-164.2990"
}
},
"phone": "+234 8109445504",
"website": "https://bolajiayodeji.com",
"company": {
"name": "PhilanthroLab",
"catchPhrase": "Multi-tiered zero tolerance productivity",
"bs": "transition cutting-edge web services"
}
};http.put("https://jsonplaceholder.typicode.com/users/2", data)
.then(data => console.log(data))
.catch(err => console.log(err));
```* DELETE Request
```js
http.delete("https://jsonplaceholder.typicode.com/users/2")
.then(() => console.log(data))
.catch(err => console.log(err));
```# Demo
Demo [here](https://bolajiayodeji.github.io/simple-fetch-library/demo/)# Contribution Guide
```bash
git clone https://github.com/BolajiAyodeji/simple-fetch-library.git
```
```bash
cd simple-fetch-library
```
```bash
npm install
```
```bash
npm run build
```