How to remove a URL parameter using JavaScript query?

Hey everyone!

I have been using retool to build a financial dashboard using Stripe API. Since Stripe uses cursor-based pagination, I have used a API query and JavaScript Query to fetch all the records from Stripe recursively. I have set a starting_after variable in URL params as shown

I am using JavaScript query to call this query recursively in combination with starting_after inside additionalScope till I get all data. This is how my JS code looks like

const fetchAllCharges = async (starting_after, records) => {
    const queryResult = await stripe_charges_api.trigger({
      additionalScope: {
        starting_after: starting_after == null ? '<some-id>' : starting_after
      onSuccess: function (data) {

    records = records.concat(;

    if (queryResult.has_more) {
      const lastCharge =[ - 1];
      return fetchAllCharges(, records);
  return records;

return await fetchAllCharges(null, []);

The issue is when the request is sent first time we don't have starting_after param because we want first n results and we can't pass null or '' because Stripe doesn't allow it. We somehow have to remove that in the first request. Currently, I am manually doing that by having a check that if the request is first then pass a valid first ID. Anybody can help about how to do that in a better way? Any lead would be appreciated.


Does it work if you make the key itself dynamic?

Hey @bca ! Thanks for taking your time and helping me. It works perfectly. Much appreciated


1 Like