Pagination, setting stop condition

Describe the problem/error/question

I’m retrieving from an API a list of conversations. There’s a page parameter, and for every request I get 25 items.
I added pagination options and, using pageCount+1, I’m able to retrieve several pages.
The problem comes with the condition I have to set so that the module stops executing when there’s no more content.

If i call this API and set the page to 200, I get the following (simplified) response:


[
  {
    "data": {
      "meta": {
        "mine_count": 64,
        "assigned_count": 64,
        "unassigned_count": 358,
        "all_count": 422
      },
      "payload": []
    }
  }
]

The key here is that the array payload is empty. I should be able to set the condition so that, if the current response’s payload is empty, then stop making HTTP requests.

I also tried with other options, like creating a set field, and update it after an if condition… It didn’t work neither. Plus, it seems like a more complex solution, and i believe that i’m near to getting this fixed. The only thing i need is the proper condition to stop :S

Can anyone help me solve this? Thanks in advance!

What is the error message (if any)?

Please share your workflow

Information on your n8n setup

  • **n8n version: 1.60.1
  • **Database (default: SQLite): Postgress
  • **n8n EXECUTIONS_PROCESS setting (default: own, main): Default
  • **Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • **Operating system: ubuntu server 22.04

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
1 Like

Welcome to the community @Javibg6 !

Tip for sharing information

Pasting your n8n workflow


Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.

```
<your workflow>
```

That implies to any JSON output you would like to share with us.


I think you are missing body in your expression. It could look like this:

{{ $response.body.data.payload.isEmpty() }}
1 Like

Thanks Ihortom! You are right, it worked!!
Simple and effective solution. chatGPT got me trying crazy stupid things, but i knew it should be a simple condition.

Thanks a lot! I will edit the JSON so that it is easier for others to see!

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