[GH-ISSUE #3329] [feature]: Set environment variables from Script #1107

Closed
opened 2026-03-16 18:35:50 +03:00 by kerem · 3 comments
Owner

Originally created by @joaonunogomes on GitHub (Sep 7, 2023).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3329

Is there an existing issue for this?

  • I have searched the existing issues

Summary

Support setting environment variables from the script tab

Why should this be worked on?

When working with a big API, with several endpoints it's very helpful to be able to store data from a response, to use on another request.
Example flow:

Given an authenticated user
I want to create a new order

For that, I would need to first create a new access token for the user and afterward use that same token on the Authorization header, when creating a new order.

Setting variables from the script would allow storing the access token on a variable, to use later on the request to create the order.

Originally created by @joaonunogomes on GitHub (Sep 7, 2023). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3329 ### Is there an existing issue for this? - [X] I have searched the existing issues ### Summary Support setting environment variables from the script tab ### Why should this be worked on? When working with a big API, with several endpoints it's very helpful to be able to store data from a response, to use on another request. Example flow: Given an authenticated user I want to create a new order For that, I would need to first create a new access token for the user and afterward use that same token on the Authorization header, when creating a new order. Setting variables from the script would allow storing the access token on a variable, to use later on the request to create the order.
kerem 2026-03-16 18:35:50 +03:00
  • closed this issue
  • added the
    feature
    label
Author
Owner

@liyasthomas commented on GitHub (Dec 8, 2023):

It seems this feature is already available in Hoppscotch, hence I'm closing this ticket.

Documentation: https://docs.hoppscotch.io/documentation/getting-started/rest/pre-request-scripts#setting-environment-variables

<!-- gh-comment-id:1847533990 --> @liyasthomas commented on GitHub (Dec 8, 2023): It seems this feature is already available in Hoppscotch, hence I'm closing this ticket. Documentation: https://docs.hoppscotch.io/documentation/getting-started/rest/pre-request-scripts#setting-environment-variables
Author
Owner

@joaonunogomes commented on GitHub (Dec 8, 2023):

Hi @liyasthomas, from what I was able to check it's on possible to set variables on pre-request scripts. The goal is to have the possibility to set env variables through testing scripts (scripts that run after the request).

Please let me know if it makes sense for you :)

<!-- gh-comment-id:1847611639 --> @joaonunogomes commented on GitHub (Dec 8, 2023): Hi @liyasthomas, from what I was able to check it's on possible to set variables on **pre-request** scripts. The goal is to have the possibility to set env variables through testing scripts (scripts that run after the request). Please let me know if it makes sense for you :)
Author
Owner

@liyasthomas commented on GitHub (Dec 9, 2023):

Scripting APIs are unified across the pre—request scripts and test scripts. You can use the same code to set environment variables from test scripts.

<!-- gh-comment-id:1848017856 --> @liyasthomas commented on GitHub (Dec 9, 2023): Scripting APIs are unified across the pre—request scripts and test scripts. You can use the same code to set environment variables from test scripts.
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#1107
No description provided.