Caching not taking curry into account

I have the following code to fetch a list of users, including requesters and agents:

async function getUsers(department_id, page_num = 1, index = 2) {
  const query_params = {};

  if (department_id === "") {
    department_id = null;
  }

  if (department_id) {
    query_params.query = `department_id:${department_id}`;
  }

  const content = {
    query: query_params,
    query: {
      ...query_params,
      include_agents: true
    },
    cache: true,
    context: { page: page_num }
  };

  try {
    const result = await client.request.invokeTemplate('getUsers', content);
  } catch (error) {
    onError('Error fetching users.', error);
    return [];
  }
}

When caching is enabled, the request does not consider the updated query_params.query values. For instance, if I first filter by department x and then by department y, the result still shows department x instead of department y.

How can I adjust the code to ensure that the query parameters are properly updated when caching is used?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.