chain-request
A simple chainable, readable object with the intense to make speaking HTTP sane.
Installation
> npm install --save chain-request
Usage
Just include the module and name it, e.g.:
var request = ;
Examples
Use the google REST-API
data v: '1.0' q: 'test' ;
Upload a file with authorization Header
data'app.zip'
Get a specific jira task
API
Functions
- Request([debug])
A simple chainable, readable object with the intense to make speaking HTTP sane.
- get() ⇒
object
Make a get request
- put() ⇒
object
make a put request
- post() ⇒
object
make a post request
- patch() ⇒
object
make a patch request
- delete() ⇒
object
make a delete request
- options() ⇒
object
make a options request
- head() ⇒
object
make a head request
- data(data) ⇒
object
set the data for the request
- addHeader(key, value) ⇒
object
add a header
- allowUnauthorized() ⇒
object
Don't verifie against the list of supplied CAs.
- addAuthorizationHeader(authStr) ⇒
object
set a authorization header
- setSendContentType(contentType) ⇒
object
set which type of format you want to send, default ist json
- sendsPlain() ⇒
object
function to send plain text to the server only make sense with post or put
- sendMultipart() ⇒
object
defines a multipart request for files, used with post() and data(filename)
- setBufferSize(bufferSize) ⇒
object
set the buffer size for a multipart request default is 4 * 1024
- setEncoding(encoding) ⇒
object
set the response encoding, default is utf-8
- expects(type) ⇒
object
set the format for the send callback, default is json
- send([callback]) ⇒
object
perform the previously created request
Kind: global function
Param | Type | Default | Description |
---|---|---|---|
[debug] | boolean |
false |
enable debugging with true |
object
get() ⇒ make a get request
Kind: global function
Returns: object
- self
object
put() ⇒ make a put request
Kind: global function
Returns: object
- self
object
post() ⇒ make a post request
Kind: global function
Returns: object
- self
object
patch() ⇒ make a patch request
object
delete() ⇒ make a delete request
Kind: global function
Returns: object
- self
object
options() ⇒ make a options request
Kind: global function
Returns: object
- self
object
head() ⇒ make a head request
Kind: global function
Returns: object
- self
Kind: global function
Returns: object
- self
object
data(data) ⇒ set the data for the request
Kind: global function
Returns: object
- self
Param | Type | Description |
---|---|---|
data | object |
data as json object |
object
addHeader(key, value) ⇒ add a header
Kind: global function
Returns: object
- self
Param | Type | Description |
---|---|---|
key | string |
header key |
value | string |
value of the header entry |
object
allowUnauthorized() ⇒ Don't verifie against the list of supplied CAs.
Kind: global function
Returns: object
- self
object
addAuthorizationHeader(authStr) ⇒ set a authorization header
Kind: global function
Returns: object
- self
Param | Type | Description |
---|---|---|
authStr | string |
authirization string |
object
setSendContentType(contentType) ⇒ set which type of format you want to send, default ist json
Kind: global function
Returns: object
- self
Param | Type | Description |
---|---|---|
contentType | object |
a valid content type |
object
sendsPlain() ⇒ function to send plain text to the server only make sense with post or put
Kind: global function
Returns: object
- self
object
sendMultipart() ⇒ defines a multipart request for files, used with post() and data(filename)
Kind: global function
Returns: object
- self
object
setBufferSize(bufferSize) ⇒ set the buffer size for a multipart request default is 4 * 1024
Kind: global function
Returns: object
- self
Param | Type | Description |
---|---|---|
bufferSize | number |
size in byte |
object
setEncoding(encoding) ⇒ set the response encoding, default is utf-8
Kind: global function
Returns: object
- self
Param | Type | Description |
---|---|---|
encoding | string |
a valid encoding |
object
expects(type) ⇒ set the format for the send callback, default is json
Kind: global function
Returns: object
- self
Param | Type | Description |
---|---|---|
type | string |
a valid content type |
object
send([callback]) ⇒ perform the previously created request
Kind: global function
Returns: object
- self
Param | Type | Description |
---|---|---|
[callback] | function |
function called when the request is ready |