bruno icon indicating copy to clipboard operation
bruno copied to clipboard

JavaScript API changed, unable to set variables,

Open joe-gre opened this issue 1 year ago • 4 comments

I have checked the following:

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

Describe the bug

I recently updated Bruno to the latest version and noticed my pre request scripts were failing because bru.getProcessEnv() and bru.getVar() were null. I see now that the bru object no longer has these functions and instead has processEnvVars and requestVariables properties. The documentation only mentions the functions that are no longer present.

The issue I have is though I can retrieve variables using the properties mentioned above, I can't set them there. The bru.setVar() function was removed. If I assign values to them, they aren't actually saved. I need to be able to save variables for my login flow.

.bru file to reproduce the bug

No response

Screenshots/Live demo link

image

image

joe-gre avatar Jul 16 '24 03:07 joe-gre

I have reproduced this issue with bruno versions 1.20.4, 1.20.1, 1.19.0 and 1.17.0

joe-gre avatar Jul 16 '24 03:07 joe-gre

I'm not sure i understand your issue correctly, you can't log "bru.getVar" but you can still use the method : image Logs will look like that : image

bpoulaindev avatar Jul 16 '24 08:07 bpoulaindev

Indeed, something is wrong. bru.getVar is not working. Version: 1.22.0

Screenshot 2024-07-26 at 12 23 33

Screenshot 2024-07-26 at 12 21 37

equiman avatar Jul 26 '24 17:07 equiman

I found the solution in other issue, use bru.getRequestVar() instead of bru.getVar()

https://github.com/usebruno/bruno/issues/2556#issuecomment-2228163546

equiman avatar Jul 31 '24 14:07 equiman

I've tested both of these APIs in the latest version, and they're working fine. I'm closing this issue, but feel free to reopen it if the problem persists.

image

anusree-bruno avatar Dec 30 '24 07:12 anusree-bruno