Function Output
The best way to communicate with your backend is by returning an object from triggerHandler
. A JSON serialized version of this object will be sent to your webhook and you will be able to query its contents in your backend.
NOTE: If your function ends without a return statement, or encounters an empty return statement (ie.
return;
), then it will be understood that you do not intend to send anything to the function's webhook. To make sure that something is sent, any defined, not-null value must be returned. For example, an empty string (return "";
) or an empty JSON object (return {};
) will be sent to the webhook.
By default, the function's should_send_std_streams
property is set to true
and any content that is printed to either stdout
or stderr
will be sent to the webhook as strings along with the function's result object. This is not recommended for production use, but can be useful for debugging. When should_send_std_streams
is true
a result will be sent when the function returns a value, or when the function has stdout
or stderr
data, or both.
export function triggerHandler(context, data) {
console.log("sample stdout log");
console.error("sample stderr log");
return { context: context, data: data };
}
-
Webhook payload with streams
{ "return_value": { "context": { ... }, "data": { ... } }, "stdout": "sample stdout log\n", "stderr": "sample stderr log\n" }
-
Webhook payload without streams
{ "context": { ... }, "data": { ... } }
Updated about 2 months ago