mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[GH-ISSUE #3329] [feature]: Set environment variables from Script #1107
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#1107
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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?
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.
@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
@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 :)
@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.