injectar
Inject a fake http request to test, debug your server logic with ease. Using light-my-request internally. Provide friendly and chainable APIs based on light-my-request
.
Install
npm install injectar
or
yarn add injectar
Usage
const injectar = { res res} })
API
Check the document for light-my-request for more.
constructor (dispatchFunction[, options])
The constructor recieves two arguments: the dispatch function and the options to be passed to the light-my-request
instance.
get
post
put
delete
head
options
patch
trace
The above all determine the request method.
body
Add body to request. Can be a string, Buffer, Stream or object (will be treated as JSON format).
body foo: 'bar' })
headers
Add request headers.
headers foo: 'bar' })
header
Add a single request header.
})
NOTE: If followed by a headers
method, the value provided by headers
will override the previous set headers, instead of combining them.
payload
An alias for body
.
query
Add querystring to url.
})