Share feedback, ideas and get community help

D
F
M
a
g

load a variable with an array/list via query string

How would this be done?

I tried it like this:

https://mydomain.com/?MyArray=["007BFF","007BFF","00FF05","00FF05","00FFFB","C800FF","C800FF","FF0000","FF0000","FF9500","FF9500","FFEA00","FFEA00","FFEA00","FFFFFF"]

And it just loads that as the text string, when I try to access the array with

{{={{MyArray}}[0]}}=}} etc, I just get

[
"
0

Just the characters in the string

I tried it even encoding the query to

%5B%22007BFF%22%2C%22007BFF%22%2C%2200FF05%22%2C%2200FF05%22%2C%2200FFFB%22%2C%22C800FF%22%2C%22C800FF%22%2C%22FF0000%22%2C%22FF0000%22%2C%22FF9500%22%2C%22FF9500%22%2C%22FFEA00%22%2C%22FFEA00%22%2C%22FFEA00%22%2C%22FFFFFF%22%5D


But I get the same result.

Is it possible to load a variable with an array/list via the query string, or would I need to instead send a reference to a table/db and then load the array/list in the bot? (that would just make it all more cumbersome).

Thanks!
B
l
2 comments
There is more than one way to handle arrays in URL parameters, here is an example of how I handle it ๐Ÿ‘‡๐Ÿผ

In the URL: https://your_viewer_domain/your_bot_name?my_array=a,b,c

The "a,b,c" part is read as a string, so when setting the variable I transform it into an array in two steps:
  1. I instantiate the variable
  2. I check the type of the variable and then transform it into an array with the javascript split method.
Test the flow I attached, maybe it will clarify a bit.
Add a reply
Sign up and join the conversation on Discord
Join