*response
Summary
*response selects how an HTTP response, loaded value, adapter action result, or WebSocket message is written back into Sercrod host data.
Alias:
n-response
*response does nothing by itself. It is read by directives that explicitly produce a response/result and support response placement.
Used By
*post*api*fetch*upload*load.file,*load.session, and*load.store*websocket- adapter action directives such as
*camera,*clipboard.read,*audio-capture.stop,*geolocation.current,*network-status.current, and*share
*download does not write response data.
Whole Response
Quoted strings select a data path for the whole response:
<button *post="'/api/save'" *keys="form" *response="'result'">
Save
</button>
This writes:
data.result = response;
Unquoted values are evaluated in the current data scope:
<button *post="'/api/save'" *response="target_key">Save</button>
If target_key is "form.note", the whole response is written to data.form.note. Missing intermediate objects are created; dotted names are not literal property names.
Response Map
Object form maps selected response values into Sercrod data paths:
<button
*post="'/api/profile'"
*keys="profile"
*response="{ user.name: response.profile.name, user.nicename: response.profile.nicename }">
Save
</button>
Left side:
- A Sercrod data path.
- Dot paths are allowed, such as
user.name. - Do not prefix with
data.. - Computed paths, bracket syntax, and function calls are not allowed.
Right side:
- Evaluated against a response scope.
response,$response, andvaluerefer to the parsed response.- Literals are allowed.
Examples:
*response="{ user: response }"
*response="{ user: response.user }"
*response='{ user.name: "tom" }'
Default Behavior
Every successful request or supported adapter action mirrors the parsed response/result to $response unless that directive documents a narrower transient slot.
If *response is omitted, normal host data is not changed for communication directives that only mirror to $response. *fetch keeps its historical root replacement behavior when no *response is present.