Using #each and queryParamRaw when there's only a single queryParam #1259
-
Hi. I'm trying to mock an API that accepts one to many instances of a queryParam called "id". Iterating through this with #each and queryParamRaw works fine if there are 2+ instances of "id", but if there's only one, the "each" section doesn't get executed. Is there a way to make this work regardless of how many ids are present in the call? Example call: Mock Setup:
This works as expected and produces this output:
However if the call is:
I was able to get the desired output by adding an "else" into the mock but that feels cumbersome as I have to repeat the mock setup and replace instances of "this."
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, there is no easy solution as the default behavior of the server we are using is to parse single query parameters as strings or as arrays when multiple occurences are found. |
Beta Was this translation helpful? Give feedback.
Hi, there is no easy solution as the default behavior of the server we are using is to parse single query parameters as strings or as arrays when multiple occurences are found.
However, you could handle this a bit differently to simplify your code after, using split/join and a variable: