0.1.6 • Published 9 years ago

oo-http v0.1.6

Weekly downloads
1
License
WTFPL
Repository
-
Last release
9 years ago

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

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.0.2

9 years ago