Closed patrickhuy closed 8 months ago
That's actually intentional. I separate the regions that these do not share the variables. Exception is when multiple cells are executed at once, then the variable scope is not always reset, but that could be explicitly enabled. You should use global regions (region with no name and no request) for your case.
{{
exports.foo = 'bar';
}}
###
GET https://google.de/?q={{foo}}
###
GET https://google.de/?q={{foo}}
The idea behind this is that all regions can always be executed independently. If they need variables from other regions, these should be referenced explicitly using @ref
.
Mh, the original use-case is/was to set variables in "post-request" scripts based on the API response with a "m-n" structure. So:
# create job using method A
POST /job
{{
exports.id=1;
}}
###
# create job using method B
POST /job
{{
exports.id=2;
}}
###
# get job status
GET /job/{{id}}
###
# delete job
DELETE /job/{{id}}
the intention is that one of the "create job" methods will be used (not nescessarily both or in that order) but the id of either would become available in "get job status". I therefore can not @ref
the "correct" one.
In the "httpYac" extension this also works fine as is. In "httpBook" it does not. Does useRegionScopedVariables
not default to false? I also tried setting it to false but it did not change anything. Setting it to true did make this no longer work in httpYac.
vscode-httpyac and httpbook may differ from each other in detail here. The reason is that each cell is considered as a separate file by vscode and I create a virtual httpFile but I am missing some details like the scoped variable store. ... Ok yeah you got me. I will align both approaches.
Your example should work with the new version v6.2.3
Can confirm, it works nicely! :)
thx for your feedback.-)
When working with variables like this
The second request will fail with
For unknown reasons I had it randomly work but most of the time it does not work. In httpyac it works fine.