Core
Framework v2.x
2

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;
NameTypeDescription
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:

NameTypeDescriptionDefault
status
integer
KuzzleRequest status code, following the HTTP standard200
headers
JSONObject
Additional response protocol headersnull
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'
  }
});