-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change variable's current value #195
Comments
To set variables, you can simply add them inline right before the request (see https://httpyac.github.io/guide/variables.html#inline-variables).
Or alternatively you could import an .env file, Intellij Idea format or variables from a central http file. It would also be possible to fill them dynamically. |
The alternative to import env/http files I'm already using but when I set some variable using a script after some response, I can't change the current value again just changing the imported file. Even so, I can go with your first solution. Nevertheless, if we could change the variable inside the extension's |
@klutzer How would you solve the data problem here? I could then only allow the input of text, since VSCode otherwise does not provide me with any controls see https://code.visualstudio.com/api/references/vscode-api#InputBox). Alternatively, only JSON would work, but this would complicate the input of simple text. |
I don't know if this is a viable option, but maybe we can able user to put some arbitrary JS code and set the variable the same way you do in |
Another thing I've noticed, is that if I change some environment variable (first defined in |
@klutzer The behavior could be a bug. I have a certain order for loading the variables (default > config (file or vscode) > env > cached variables > variables) and it can happen that the variable from the environment is overwritten afterwards. The object displayed as variables in VSCode is not used directly at all, but is only the result of the last execution. I try to separate the variables pots (environement or variable of httpregion). Your description indicates an error in the separation and an example of the error would be interesting. |
Yep, changing variables from the UI isn't so trivial indeed. An example of the environment variable behavior: .env:
file1.http:
file2.http
To simulate just execute the requests in order (first, second..). In my understanding, the |
@klutzer I do not have global variables. The environment is global. The variables are always present only in the respective httpRegion. Since this approach was too strict for myself, the variables are leaking in the same file (useRegionScopedVariables = false). To access variables from other files, this file must be imported, and if necessary also the respective HttpRegion. The whole approach is driven by test execution. My goal was that the execution is reproducible and automatable. Your requirement is important during the development of the request that you can easily change the call. In this case I simply adjust the request body directly or try to avoid variables and use multiple requests. I want to focus on the development of the backend and miinimize the cognitive load for tooling. |
In this case, knowing that environment is global, when I change the env (setting new value to env For variables (defined in I know this can be undesired, I'm just raising some possibilities to have envs similar to extensions like ThunderClient, where we have global envs as default, and an |
Is there any way to change the current variable value on VSCode? Extensions like thunder-client offers a way to simply change variables when we're using some value in different requests/files
The text was updated successfully, but these errors were encountered: