Skip to content

Use variables in required scripts #103

Answered by AnWeber
Sebaestschjin asked this question in Q&A
Discussion options

You must be logged in to vote

The easiest thing to do is to pass you the variables as objects. Either just use this or in my eyes better, use the variables explicitly.

{{+request
    require("./script").setHeaders(request, this)
}}
{{+request
    require("./script").setHeaders(request, { some_value, some_other_value})
}}

If you require the script in several places, you can have a look at the hook api. That's exactly what it's for and it has easier access to the variables and interface. With this I extend httpyac with the companies internal api

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Sebaestschjin
Comment options

Answer selected by Sebaestschjin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants