Update HTTP Request parameters dynamically

Hi there!

I’m working on a workflow witch I use the HTTP request. I wanna get data from Vitally’s REST API.

However, as you can see here (Vitally's REST API - Vitally Help Center) “In addition to an array of results, the response will return a “next” property which can be used to access the subsequent page. The “next” property will be “null” when the end is reached and there are no more pages.”

When this “next” property is created I need to update my HTTP Request parameter so I can access the subsequent page. And I need looping until there are no more “next” result

Someone has any idea how can I do this?

Hi @Lucas_Santos
have a look at this template: Handle pagination in HTTP Requests | n8n workflow template

This is about handling pagination in HTTP requests so it should solve your problem.
It is a bit outdated but the overall concept is there.

Let me know if this helps

1 Like

Hi @giulioandreini

It’s almost worked but in the “Set next URL” note don’t how should I do

What am I missing?

Hi @giulioandreini

Update: I did it! My problem now is when I finally get all data there is no output data returned from the “Combine all data” node.

I left my JavaScript code in the print so you can see what I’m doing wrong

May you help me?

Hey @Lucas_Santos,

Have you tried using something like the below to start?

let results = [],
  i = 0;

do {
  try {
    results = results.concat($("HTTP Request").all(0, i));
  } catch (error) {
    return results;
} while (true);

1 Like

Hey @Jon

I will no longer need to combine all the data. Instead, I will append my results to Google Sheets. In this way, it worked precisely as I expected!


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