setResult #
Deprecated since 2.12.0
Sets the request result and status
Use request.response.configure instead, which takes a result option
Available since auto
:request.response.configure({ result, status, headers, format: 'raw' });setResult still works and will only be removed in a major version. Unlike configure, it resets the status to 200 when no status option is given.
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 #
// Deprecated
request.setResult(null, {
raw: true,
// HTTP status code for redirection
status: 302,
headers: {
'Location': 'http://kuzzle.io'
}
});
// Equivalent
request.response.configure({
result: null,
format: 'raw',
status: 302,
headers: {
'Location': 'http://kuzzle.io'
}
});