I'm sorry for the question but I haven't really figured out how to use the environment variables.
I have an "api.http" file with the requests, and a "env.http" file with the variables, but I can't make it work.
Can you please explain me how to do this?
Thanks
hey Gjoforte,
You can add "rest-client.environmentVariables" to Vscode user setting or to Vscode workspace file (".code-workspace")
In the Json file , under setting add the _restCleint.code-workspace_ env config.
after saving it, press F1 and search for Rest Client: Switch Environment , you should be able to see the environments.
hope you will find it useful.
i.e:
**"settings": {
"rest-client.environmentVariables": {
"$shared": {
"version": "v1",
"prodToken": "foo",
"nonProdToken": "bar"
},
"local": {
"version": "v2",
"host": "https://www.cnn.com",
"token": "{{$shared nonProdToken}}",
"secretKey": "devSecret"
},
"production": {
"host": "example.com",
"token": "{{$shared prodToken}}",
"secretKey" : "prodSecret"
}
}
**
Regards,
Eran
@emgood thanks for your reply, @gjoforte you can follow the instructions from @emgood
hi all,
how does it know which environment you are running in? e.g "local" or "production".
Where do you set this?
Thanks
oh I found the it in the documentation. thank you for this great extension Huacho.
"Currently, active environment's name is displayed at the right bottom of Visual Studio Code, when you click it, you can switch environment in the pop-up list. "
Most helpful comment
hey Gjoforte,
You can add "rest-client.environmentVariables" to Vscode user setting or to Vscode workspace file (".code-workspace")
In the Json file , under setting add the _restCleint.code-workspace_ env config.
after saving it, press F1 and search for Rest Client: Switch Environment , you should be able to see the environments.
hope you will find it useful.
i.e:
Regards,
Eran