Make a virtual request to a running Sails instance.
sails.request(url, body, callback)
This method can be used on a instances that have been started with
sails.load(), which are not actively listening for HTTP requests on a server port. This makes it useful for testing scenarios where running
sails.lift() is not necessary. However, it should be noted that the data may not be processed in exactly the same way as an HTTP request; in particular, a much simpler body parser will be employed, and Express middleware such as the static asset server will not be used.
|1||request (or url)||The virtual request to make. If specified as a string, this should be an address containing an optional method and a path, e.g.
|2||body||(optional) A JSON-serializable value to use as the request body. This argument will override the
|3||callback||(optional) A callback to be called with the virtual response.|
request argument is specified as an object, it can have the following properties:
||(required) The route in the Sails app to make a request to, with an optional HTTP method prefix|
||(optional) The HTTP method to use in the request. This will override any method supplied as part of the
||(optional) Dictionary of headers to use in the virtual request.|
|1||err||If the response was unsuccessful (status code was not in the 200-399 range) this will be an object containing
|2||response||If the response was successful, this will be an object containing the full server response.|
|3||body||If the response was successful, this will be the value of
The full virtual request stream object. This is a readable stream.