AnWeber / vscode-httpyac

Quickly and easily send REST, Soap, GraphQL, GRPC, MQTT and WebSocket requests directly within Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=anweber.vscode-httpyac
MIT License
222 stars 20 forks source link

Using $global with multiple environments #207

Closed xlemassacre closed 10 months ago

xlemassacre commented 11 months ago

Hi, I have question regarding the $global variable in scripts.

I try to use that variable to write something from the response header in a global variable:

{{
  $global.logintoken = response.headers['authorization'];
}}

This is working fine when only one environment is selected. When using multiple environment (which is a really nice feature), the global variable is set in none of the selcted environments.

Would it be possible to store it to either one or all selected environments?

AnWeber commented 11 months ago

Actually, the global variable is created already per environment combination. I create a key over all environments and save the values. So if you choose the same combination you should get the previous value again. The saved object can be seen in the session tab, but unfortunately you can't see for which environments the key is valid.

image

You could view the Key in my debug view

image

I could not reproduce the error with me now. Could you please describe in more detail why the values are not reused, preferably with an example

xlemassacre commented 10 months ago

Thanks for the quick response, took me some times now to do a retest. Seems to be working now actually, but unfortunatelly I don't know whats different this time. If it happens again I'll try to add more details :)