Skip to content
This page View Markdown Open in ChatGPT Open in Claude

Global shared

Shared data globally

g.shared is used to share data between post-hooks, pre-hooks, code, and APIs.

  • If the user set a shared variable from the one API response.
g.shared.lastOutput = g.res.output;
g.shared['lastOutput'] = g.res.output
$g->shared->lastOutput = $g->res->output;
g.Shared["lastOutput"] = g.Res.Output?.DeepClone();
g.Shared.Set("lastOutput", g.Res.Output())
g.shared.set("lastOutput", g.res.output().clone());
g.shared.put("lastOutput", g.res.getOutput());
g.shared["lastOutput"] = g.res.output
  • User can get that shared variables value in another API.
const lastOutput = g.shared.lastOutput;
last_output = g.shared.get('lastOutput')
$lastOutput = $g->shared->lastOutput;
var lastOutput = g.Shared.GetValueOrDefault("lastOutput");
lastOutput := g.Shared.Get("lastOutput")
let last_output = g.shared.get("lastOutput");
Object lastOutput = g.shared.get("lastOutput");
val lastOutput = g.shared["lastOutput"]