Skip to main content

Completed Script

Asynchronously called when the HTTP response is completed, without affecting data transmission between the app and the real server. Can be used for data collection, for example, if you want to export certain data, you can create an HTTP server yourself and then use HTTPClient in this script to pass the data to the server.

The entry function for scripts is async function onSessionCompleted(context, url, request, response), and specific script examples can be found in the Script API Reference.

app ------------------------------------> real server
app <------------------------------------ real server
|
⇣
Call onSessionCompleted(context, url, request, response)

As shown in the diagram above, onSessionCompleted is asynchronously called after the server returns a response, with parameters (context, url, request, response).

Scripts can also load shared code with require('@libs/<key>'): built-in libs (@libs/base64, @libs/hex) are bundled with the app, so session-completed scripts can use them out of the box (see the require guide).

The JavaScript API used by Hodor is documented in the Script API Reference.