mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-25 16:55:59 +03:00
[PR #231] [MERGED] Feature/pre request script #2502
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#2502
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?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/231
Author: @nickpalenchar
Created: 10/30/2019
Status: ✅ Merged
Merged: 10/30/2019
Merged by: @liyasthomas
Base:
master← Head:feature/pre-request-script📝 Commits (4)
668f99cpre-request script working36fb517update search tearm and parse more data1bf17d5Merge branch 'master' into feature/pre-request-scriptad1c745⚡ Added β symbol to , few minor UI updates before production deployment📊 Changes
4 files changed (+83 additions, -7 deletions)
View changed files
📝
components/history.vue(+7 -0)➕
functions/preRequest.js(+17 -0)➕
functions/templating.js(+7 -0)📝
pages/index.vue(+52 -7)📄 Description
fixes #218
scrapped the old branch
feature/dynamic-headersafter merge woes (will delete soon).Lots more to think about, but I feel it satisfies mvp (and would love to get this in master so I can take a break from keeping it up-to-date manually 😅)
Request section has a
codebutton. When clicked, it enables pre-request scripts. A pre-request script section appears above where javascript can be entered.pre-request script has access to a postwoman api object (
pw) that can be interacted with. Right now the only thing to do ispw.environment.set("key", "value")to set a variable that can be used in areas of the request. Note this is native javascript, so any js method can be used. Final values are all treated as strings.Test by setting something in the pre-request script
pw.environment.set("route", "/api/users");and replacing parts of the request within double angle brackets (path =<<route>>). Response should function the same as if the final value was statically typed.Additionally, requests made this way end up in history with the same
codeicon. Hovering over it informs the user that this entry in the history used pre-request scripts. Due to it's highly dynamic potential, you could say that note serves as a warning!tangentially -- @NBTX can you make the request-chaining into its own issue? I realized it's quite separate from this one so it would be good to address that after this.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.