oo-http
v0.1.6
Published
npm install oo-http
Downloads
5
Readme
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 fieldvalue
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 bodycallback
function(error, response)
Response#statusCode
http status code
Response#headers
header dictionary
Response#getHeader(name)
get response header