Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the result of req.getBody() in pre request is not be setup with Vars. #3752

Open
2 tasks done
finscn opened this issue Jan 8, 2025 · 3 comments
Open
2 tasks done
Assignees
Labels
bug Something isn't working

Comments

@finscn
Copy link

finscn commented Jan 8, 2025

I have checked the following:

  • I use the newest version of bruno.
  • I've searched existing issues and found nothing related to my issue.

Describe the bug

there is a env-Var :

    userName  =  "tester001"

and I set the request Body (use json) like this :

{
    "name" : "{{userName}}"
}

Then , I write some script in pre request phase :

const body = req.getBody()

I hope body is

{
    "name" : "tester001"
}

but it's

{
    "name" : "{{userName}}"
}

the {{userName}} not be set with env-var.

.bru file to reproduce the bug

No response

Screenshots/Live demo link

none

@finscn finscn added the bug Something isn't working label Jan 8, 2025
@finscn
Copy link
Author

finscn commented Jan 8, 2025

bruno ver 1.37.0

@sreelakshmi-bruno sreelakshmi-bruno self-assigned this Jan 8, 2025
@sreelakshmi-bruno
Copy link
Collaborator

sreelakshmi-bruno commented Jan 8, 2025

Hi, this is an intended behavior that the env-vars shouldn't get interpolated in the pre-request script. It'll be interpolated when the request is sent and you can console it in the post-response. Can you try doing the same in post-response? Thanks!

@finscn
Copy link
Author

finscn commented Jan 9, 2025

Hi, this is an intended behavior that the env-vars shouldn't get interpolated in the pre-request script. It'll be interpolated when the request is sent and you can console it in the post-response. Can you try doing the same in post-response? Thanks!

I want to encrypt the requested data. so I intended flow is :

  1. set env-vars to body-data
  2. encrypt the data
  3. send the data

if in bruno , the set env-vars to body-data phase is the last step before send , How can I encrypt the data ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants