Closed warrenb-onware closed 1 year ago
There are a few small problems in your example.
Your example using $global
is missing the point for accessing the variable (change $globalgblIp
to $global.gblIp
)
HEAD https://api.ipify.org?gblIp={{$global.gblIp}}
The fact that the example with the use of the exports
variable does not work has to do with the way VSCode allows access to the notebook cells. Actually, I allow implicit access to variables of other regions in the same file. However, each cell is passed by VSCode at the interface as a separate file. Thus one must currently specify the variables usage explicitly with # @ref
.
# @name foo
GET https://api.ipify.org?format=json
{{
$global.gblIp = response.parsedBody.ip
exports.lclIp = response.parsedBody.ip
}}
###
# @ref foo
HEAD https://api.ipify.org?lclIp={{lclIp}}
...
I'll check if I can adjust the logic here to read all cells in one go.
Thanks for the catch of the typo for the $global - I'll probably use that for now.
I don't really understand variable scopes as presented in your response - if each cell is a separate file, then assigning a value to a variable in a cell (as in the latter part of my repro) should be a no-op, and yet such variables can be used in other cells. Perhaps these are treated as a special case?
To me, the need to reference a particular message would be more obvious if exported variables were actually properties on the message's object. So # @ref foo
then ...?lclIp={{foo.lclIp}}
. This would still be useful - we're encapsulating the logic for parsing the response.
I don't quite understand the last comment. Using the response directly was actually my intention as one should use `# @ref'.
I'm sorry - I thought your example in the previous comment was specific to files, and not books. But I see that using @ref
pulls into scope the ref
variable, but also pulls in any variables created by exports
into the scope as well.
This isn't what I would expect, but I'm happy that it works.
@warrenb-onware Books and files are the same. I convert all notebook cells to a virtual file. Using httpbook or httpyac should provide the same output. Maybe a improvement would be to auto ref all cells of.the same file.
When I try to save a result from a post-response script (either with
exports
or$global
), no value seems to be saved.repro.zip