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

not available global var in callback #1300

Closed
randll32 opened this issue Jan 31, 2024 · 3 comments · Fixed by #1336
Closed

not available global var in callback #1300

randll32 opened this issue Jan 31, 2024 · 3 comments · Fixed by #1336
Assignees
Labels
bug Something isn't working

Comments

@randll32
Copy link

not available global var in callback
variables are not available
in callback calls request parameters are not available in callback calls

Steps to Reproduce

I tried using SetGlobalVar

{{setGlobalVar 'test123' (int 0 99999999999)}}

in callback
test123={{getGlobalVar 'test123'}}

the variable is not available

Mockoon version:

6.0.1

OS / OS version:

Linux Ubuntu 22.04, etc -->

@Javierdelared
Copy link

Hello, I'm experiencing the same issue. I want to parametrize some fields of the body of the callback based on the initial call, but it's not possible to do with global variables, I don't know if there is any other way.

Here's a minimal example of the problem:
testCallback.json

If I make one call to the mock, the return of the callback is empty. However, if I repeat the call a second time, the field is filled correctly with the global variable.

Mockoon version: 7.0.0
OS / OS version: Windows 10

255kb added a commit that referenced this issue Mar 11, 2024
Callbacks were executed before generating the response template, they couldn't access global vars.
Move execution before sending but after generating templates.

Closes #1300
@255kb 255kb self-assigned this Mar 11, 2024
@255kb 255kb added the bug Something isn't working label Mar 11, 2024
@255kb
Copy link
Member

255kb commented Mar 11, 2024

Thanks for reporting.
Indeed callbacks are executed just before sending the response but also before generating the response template.
I will move the callbacks in-between response template generation and actual response sending.

255kb added a commit that referenced this issue Mar 11, 2024
Callbacks were executed before generating the response template, they couldn't access global vars.
Move execution before sending but after generating templates.

Closes #1300
255kb added a commit that referenced this issue Mar 11, 2024
Callbacks were executed before generating the response template, they couldn't access global vars.
Move execution before sending but after generating templates.

Closes #1300
255kb added a commit that referenced this issue Mar 11, 2024
Callbacks were executed before generating the response template, they couldn't access global vars.
Move execution before sending but after generating templates.

Closes #1300
255kb added a commit that referenced this issue Mar 12, 2024
Callbacks were executed before generating the response template, they couldn't access global vars.
Move execution before sending but after generating templates.

Closes #1300
255kb added a commit that referenced this issue Mar 12, 2024
…#1336)

Callbacks were executed before generating the response template, they couldn't access global vars.
Move execution before sending but after generating templates.

Closes #1300
@255kb
Copy link
Member

255kb commented Apr 2, 2024

📦 This was fixed in v8.0.0

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
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants