Skip to content

openup/httpClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

httpClient

http library typeScript / es6

live exapmle (https://openup.github.io/httpClient/)

Method

GET http.get(url, headers : {}); // headers are Additional (Option)

POST http.post(url, params : {}, headers : {}); // params & headers are Additional (Option)

Abort http.abort(); // no args needed; cancel current request

How to use

you need to compile to JS or integrate the js file

don't forget to integrate the class file in your html 🀄 <script src="httpClient.min.js"></script>

const http = new Http(); // by default return JSON , if want text declare new Http('text');
let post_url = "http://httpbin.org/post";
let get_url = "http://httpbin.org/headers";

// for GET request 
http.get(get_url).then((res) => {
    console.log('Success : ', res);
}).catch((err) => {
    console.log('Error : ', err);
});


// for POST request **(add json as data params)**

http.post(post_url, {key : value}).then((res) => {
    console.log('Success : ', res);
}).catch((err) => {
    console.log('Error : ', err);
});


// to cancel a current request
http.abort();


About

http library typeScript / es6

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published