QRequest
A Q-promise request node module wrapper. It will produce Q-promises for request methods:
- del
- get
- head
- patch
- post
- put
Installation
npm install q-wrapped-request
Note: The module is using peerDependencies
to require Q
and request
, so your project may have its own
dependencies on both libraries installed.
Fulfillment
A fulfillment handler will receive an array of request callback params:
- response
- body
So the typical request chain may look like:
;
Constructor
A QRequest constructor will accept an options param that will call defaults
of request internally and use this
request for further requests:
;
raw
Both QRequest
class and its instances will have a raw
property for convenience.
- QRequest
raw
is just a request itself. - Instance
raw
property is a request produced by callingdefaults
as a constructor.
Getting body
For more convenience QRequest expose two utility functions to get body:
bodyIfStatusOk
Returns body
if response status is one of the allowed:
;
body
Returns body
if response status is 200:
;