oo-http

0.1.6 • Public • Published

oo-http

Installation

npm install oo-http

Usage

var http = require("oo-http");
 
http.post("/path/to/file")
    .setHeader("Content-Type", "application/json")
    .setType("json")
    .setTimeout(10000)
    .send({ a: 3 }, function(error, response) {
        console.log(response.statusCode);
        console.log(response.body);
        console.log(response.getHeader("Content-Type"));
    });

Standard methods: get, put, post, delete, head, patch, options Non-standard methods: request()

Request#setHeader(name, value)

set request header

  • name header field
  • value header value

Request#setType(type)

set response body type (https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#responseType)

  • type string identifying the response type

Request#setTimeout(ms)

set request timeout

  • timeout in milliseconds

Request#send(body, callback)

send the request

  • body request body
  • callback function(error, response)

Response#statusCode

http status code

Response#headers

header dictionary

Response#getHeader(name)

get response header

Response#body

Readme

Keywords

Package Sidebar

Install

npm i oo-http

Weekly Downloads

1

Version

0.1.6

License

WTFPL

Last publish

Collaborators

  • eleandor