Kong / insomnia

The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
https://insomnia.rest
Apache License 2.0
33.56k stars 1.87k forks source link

Pre Request Script - Incorrect value of a recursive env Variable #7548

Closed karan221 closed 1 week ago

karan221 commented 2 weeks ago

Expected Behavior

Pre Request Script

console.log(insomnia.environment.get('recursive_variable'));
// log: "value"

Actual Behavior

Pre Request Script

console.log(insomnia.environment.get('recursive_variable'));
// log: "{{ _.base_variable }}"

Reproduction Steps

Add base env variable -> { "base_variable": "value" } Add sub env recursive variable -> { "recursivevariable": ".base_variable" }

Run the pre-request script

Is there an existing issue for this?

Additional Information

No response

Insomnia Version

v9.2.0

What operating system are you using?

macOS

Operating System Version

13.6.3

Installation method

hombrew

Last Known Working Insomnia version

No response

ihexxa commented 2 weeks ago

Hello @karan221 Rendering is not enabled in the script as you are able to read variables directly from script, may I know the use case?

If you really want to render it, you could try something like this:

console.log(
    insomnia.collectionVariables.replaceIn(
        insomnia.environment.get('recursive_variable')
    )
);
karan221 commented 1 week ago

Thanks this will work