[GH-ISSUE #4695] [feature]: pw.globals.env.set feature #1749

Open
opened 2026-03-16 21:36:38 +03:00 by kerem · 1 comment
Owner

Originally created by @nesimii on GitHub (Jan 24, 2025).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4695

Is there an existing issue for this?

  • I have searched the existing issues

Summary

In Postman;

pm.globals.set("accessToken", accessToken);
pm.globals.set("refreshToken", refreshToken);

Why should this be worked on?

In the postman application, data from the response can be saved in the global environment table, can you add it?

Originally created by @nesimii on GitHub (Jan 24, 2025). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4695 ### Is there an existing issue for this? - [x] I have searched the existing issues ### Summary In Postman; pm.globals.set("accessToken", accessToken); pm.globals.set("refreshToken", refreshToken); ### Why should this be worked on? In the postman application, data from the response can be saved in the global environment table, can you add it?
Author
Owner

@yunhao-jiang commented on GitHub (Jun 24, 2025):

According to the following code:
github.com/hoppscotch/hoppscotch@580cf60766/packages/hoppscotch-js-sandbox/src/shared-utils.ts (L31C1-L57C4)

It seems pw.env.set() will set a global environment when:

  1. The variable is NOT in the current active non-global environment AND
  2. The variable is already in global environment (whether there's value assigned or not)

So to make it set to global variable, you have to remove the corresponding variable in your local environment variable and add a new (blank) entry in the global one. Then it will save to the global variable (an icon will show up).

Image

I do think that there should be a better documentation on this implementation or simply add another method that only updates global variable.

<!-- gh-comment-id:3001473426 --> @yunhao-jiang commented on GitHub (Jun 24, 2025): According to the following code: https://github.com/hoppscotch/hoppscotch/blob/580cf60766b5034e69699e2ba4bf542aaa0889de/packages/hoppscotch-js-sandbox/src/shared-utils.ts#L31C1-L57C4 It seems `pw.env.set()` will set a global environment when: 1. The variable is NOT in the current active non-global environment AND 2. The variable is already in global environment (whether there's value assigned or not) So to make it set to global variable, you have to remove the corresponding variable in your local environment variable and add a new (blank) entry in the global one. Then it will save to the global variable (an icon will show up). ![Image](https://github.com/user-attachments/assets/08493a60-3ef2-4334-a085-2b2c0ab791c1) I do think that there should be a better documentation on this implementation or simply add another method that only updates global variable.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#1749
No description provided.