0.4.2 • Published 4 years ago

gibma v0.4.2

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

gibma

A very lightweight http promise wrapper based on typescript.

Background

As a lot of other users I had to do http requests on our server, but had no library for that. So I tried several packages until I found out that node ships with the exact same functions I needed for sending my requests. This library is just a simple promise wrapper to the http module of node.

Installation

npm install gibma

Usage

Simply import the package and use the request function.

import {request} from 'gibma'

async function doMyGetRequest() {
  const response = await request('https://reqres.in/api/users', {method: 'GET'})
  const raw = response.data // this returns a string
  const json = response.json() // this returns the parsed json object
}

async function doMyPostRequest() {
  const response = await request('https://reqres.in/api/users', {
    method: 'POST', data: {name: 'gibma', job: 'best-job-ever'}
  })
  const raw = response.data // this returns a string
  const json = response.json() // this returns the parsed json object
}

This returns a customized IncomingMessage response which carries the raw data in data attribute. You can easily get the parsed json (if available) with the json function of the response.

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.1.0

4 years ago

0.3.0

4 years ago

0.2.1

4 years ago

0.1.2

4 years ago

0.2.0

4 years ago

0.1.1

4 years ago

0.0.2

4 years ago

0.3.1

4 years ago

0.1.3

4 years ago

0.0.1

4 years ago