Library for making HTTP requests using fetch API.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
easyfetchjson.js
index.html

README.md

easyFetchJson

Library for making HTTP requests using fetch API.

Files to include in your project -


  <script src="easyFetchJson.js"></script>

How to Use

Firstly, instantiate an object of the easyFetchJSON class as shown below -

const http = new easyFetchJSON();

Then make either a GET, POST, PUT, or DELETE request as shown below -

Sample GET Request

http.get('https://jsonplaceholder.typicode.com/users')
.then(data => console.log(data))
.catch(error => console.log(error));

Sample POST Request

const data = {
    name: "Salmon",
    email: "test@test.com"
};
http.post('https://jsonplaceholder.typicode.com/users', data)
    .then(data => console.log(data))
    .catch(error => console.log(error));

Sample PUT Request

const data = {
    name: "Salmon",
    email: "test@test.com"
};
http.put('https://jsonplaceholder.typicode.com/users/2', data)
        .then(data => console.log(data))
        .catch(error => console.log(error));

Sample DELETE Request

http.delete('https://jsonplaceholder.typicode.com/users/2')
    .then(data => console.log(data))
    .catch(err => console.log(err));