Skip to main content
Version: LOC v0.8 (legacy)

Result Agent

import { ResultAgent } from "@fstnetwork/loc-logic-sdk";

Finalise a JSON object as the result data. If the trigger is synchronized API route or message queue, it will be returned to the trigger, otherwise stored in LOC to be retrieved later.

Availability

  • ✗ Generic logic
  • ✓ Aggregator logic

Finalise Result

ResultAgent.finalize(value: object)

value has to be a JSON object (a JavaScript object without methods).

tip

The result agent can be used in both run and handleError functions and does not need await.

See the tutorial for tips on using result agent for error handling.

Example

ResultAgent.finalize({
status: "ok",
taskId: ctx.task.taskId,
data: {
name: "Arthur Dent",
age: 42,
},
});

status: "ok" is not the HTTP response code, but an user-defined field that indicates the task has been executed without issues.

The finalised data will be

{
"status": "ok",
"taskId": {
"executionId": "...",
"id": "..."
},
"data": {
"name": "Arthur Dent",
"age": 42
}
}