-
|
Hey, I would like to have some kind of request template, where I can inject query parameters from the cli via Is there an easy way to have a base request where I can optionally define query parameters? Thanks :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi, Yes, from what I've understood an empty value in a QP is a valid QP, so it will accept that. Currently there is a hacky way (if your request has at least one query parameter per call). It uses an executable to do logic. Example in bash: [Query]
$(bash -c 'if [ -n "$VAR" ]; then echo param=$VAR; else echo " "; fi')You can use any language, as long as it can be invoked to eval a string and can access environment variables. Example in node: [Query]
$(node -e 'if ( process.env.VAR !== undefined) { console.log("param="+process.env.VAR) } else { console.log(" ") };')But it doesn't read too nicely, esp. the printing of an empty string to get around an executable needs to have some output. So it might be better to stick all of it in it's own bash, node or whatever script and just call that executable for now. I've actually been thinking about this case too, since conditionals would be nice and I've run into similar cases as you when it would be better to have conditionals in the actual template instead of in a script by the side. I'm leaning towards multi-line executables so you can do more logic in any language of your choice and that the executable is allowed to produce no output. |
Beta Was this translation helpful? Give feedback.
Hi,
Yes, from what I've understood an empty value in a QP is a valid QP, so it will accept that.
Currently there is a hacky way (if your request has at least one query parameter per call). It uses an executable to do logic. Example in bash:
[Query] $(bash -c 'if [ -n "$VAR" ]; then echo param=$VAR; else echo " "; fi')You can use any language, as long as it can be invoked to eval a string and can access environment variables. Example in node:
But it doesn't read too nicely, esp. the printing of an empty string to get around an executable needs to have some output. …