0.1.8 • Published 14 days ago

@sekizlipenguen/connection v0.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
14 days ago

platforms npm npm

Promise based HTTP client for the browser and react, react-native

Release notes(0.1.2) 🐧 🐐

  • global setConfig method
  • response timeout(status code) 408 added
  • connectType default null - fetch (not progressbar)

Installation

yarn add @sekizlipenguen/connection
or
npm install @sekizlipenguen/connection

Performing a GET request

import connection from "@sekizlipenguen/connection";
//or const connection = require('@sekizlipenguen/connection');

connection.get('https://mocki.io/v1/8cecbd39-4cde-448f-9149-bccae2b66a0c').then((response) => {
    console.log(response);
}).catch((error) => {
    console.log(error);
});

//example `async`
async function getPenguin() {
    try {
        const response = await connection.get('https://penguin.example.com?p=1&d=1');
        console.log(response);
    } catch (error) {
        console.error(error);
    }
}

Performing a POST request

connection.post('https://mocki.io/v1/8cecbd39-4cde-448f-9149-bccae2b66a0c', {
    first_name: 'CM',
    last_name: 'Penguen'
}).then((response) => {
    console.log(response);

}).catch((error) => {
    console.log(error);
});

Methods

Method NameDescription
get(url,config)
post(url,data, config)
put(url, data, config)
patch(url, data, config)
delete(url, config)

Global Config

connection.setConfig({
    timeout: 6000 //ms
})

Config

{
    headers: {
        "content-type": "application/json",
        "X-Custom-Header": "foobar"
    },
    progress: function (e) {
        //post-put data upload event
    },
    timeout: "default 5000 ms",
    async:"default true"
}
0.1.8

14 days ago

0.1.4

14 days ago

0.1.6

14 days ago

0.1.5

14 days ago

0.1.2

2 years ago

0.1.3

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago