Using trigger's addicitonalScope for URL parameters doesn't work

We have two queries:

  1. Javascript code with a for loop. Each loop calls a rest api query and passes a different parameter via additional scope.
  2. Rest api GET query which should load the additionalScope parameter and use it as a URL parameter.

The problem is that the parameter passed via additionalScope is always undefined inside the rest api query.

When I try exactly the same setup but it's with a POST request and I use the additionalScope parameter in its body, everything works like charm.

Is that a bug or I don't see something?

And here's the javascript code:

await get_all_bookings.trigger({
  	additionalScope: {
   	 testing: value,
1 Like

Hi @sykac,

What is the value in the JS query?

testing will always be undefined in the REST query until you trigger the JS query, since that is where it is getting defined.

If it's still undefined after running the JS query, can you check the browser console? You should be able to see what value is being passed into the Rest query.

Yes, I'm talking about the case when I'm running the JS query.

It's a bit weird. I'm not sure how to directly find out what's being passed into the rest api query, but here are my insights:

  1. Refresh the page with cmd+R to start with a clear state.
  2. When I run the JS query for the 1st time after refresh, the rest api query is executed and I get a response saying "The value of offset null is invalid". So it seems the testing param caries a null value?
  3. When I execute the JS query for the 2nd time it gets executed properly and the value is passed via the param.

Another insight is when I put a loop into the JS code. In each loop I send a different param value:

  1. Refresh the page with cmd+R to start with a clear state.
  2. Run the JS loop query for the first time. Each iteration ends up with the error like the point 1. above.
  3. When I run the JS loop query for the second time (each time with a different value), the first iteration goes through and the parameter is passed, but the other iterations won't pass the new value, the rest api query is run always with the param value from the first iteration.

It's really weird. And like I said, when I'm using the same code but pass the additionalScope param to the body of a POST request, it goes through perfectly, each iterations passes a correct updated value. So it's not like I don't know what I'm doing. It seems to be relevant only to passing the param to URL parameters of a query.

@sykac Hmm, let's check the browser console to see what values are being passed to the query on the first run. In Chrome, you can access this by clicking option+command+i

You'll have to expand the object to see the values. It should look something like this: