setResult #
Sets the request result and status
Arguments #
setResult(
result: any,
options: {
status?: number
headers?: JSONObject;
raw?: boolean;
}): void;
Name | Type | Description |
---|---|---|
result | any | KuzzleRequest result. Will be converted to JSON unless the raw option is set to true |
options | JSONObject | Optional parameters |
The options
argument may contain the following properties:
Name | Type | Description | Default |
---|---|---|---|
status | integer | KuzzleRequest status code, following the HTTP standard | 200 |
headers | JSONObject | Additional response protocol headers | null |
raw | boolean | Instead of a Kuzzle response, forward the result directly to the client, without being converted to an API response payload (can be used to answer in a different format than JSON) | false |
Example #
request.setResult(null, {
raw: true,
// HTTP status code for redirection
status: 302,
headers: {
'Location': 'http://kuzzle.io'
}
});
Edit this page on Github(opens new window)