Core
Framework v2.x
2

setResult #

Sets the request result and status

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 #

request.setResult(null, {
  raw: true,
  // HTTP status code for redirection
  status: 302,
  headers: {
    'Location': 'http://kuzzle.io'
  }
});