usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
26.37k stars 1.2k forks source link

JavaScript API changed, unable to set variables, #2645

Open joe-gre opened 3 months ago

joe-gre commented 3 months ago

I have checked the following:

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 commented 3 months ago

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

bpoulaindev commented 3 months ago

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
equiman commented 2 months ago

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 commented 2 months ago

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

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