/invoke/stdout endpoint with Node.js to stream Server-Sent Events (SSE) from the Cloud Coding API. We’ll use the eventsource package, which simplifies handling SSE connections.
Installation
First, add theeventsource package to your project:
The following examples use
require for Node.js compatibility. If you are using ES modules, you can use import EventSource from 'eventsource'.Single Task Invocation
This example invokes a single task and listens forupdates and custom events from the stream.
Parallel Task Invocation
This example runs two tasks in parallel. Thecustom event’s data includes a task_name, which you can use to identify which task produced the output.