Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

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

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
```