I have read most of the articles about the above subject and where i fail is the java script code for the function node.
so here are the parameters…
my im getting the use_id from nocodb
then i call the API using the URL: http://api.com/?user={{$(‘Sourcedata’).item.json.user_id
then the API would return the data along with a field called next_max_id
Im setting the Set node to save this under the variable name next_page_id
the function node i want it to pass the URL to the HTTP request node
if next_page_id is empty, the URL will be http://api.com/?user={{$(‘Sourcedata’).item.json.user_id
if next_page_id is not empty, the URL will be http://api.com/?user={{$(‘Sourcedata’).item.json.user_id&next_max_id= next_page_id
Happy to say that i was able to solve it using ChatGPT-4
not sure if this is the best solution but here is what i did and it worked for me
The solution relies on saving the next_page_id to the global variables of the execution and then retrieve it again.
This is the code that is in the Config URL node:
// Get the global workflow static data
const workflowStaticData = $getWorkflowStaticData('global');
// Access its data
let next_page_id = workflowStaticData.next_page_id || null;
let url;
if (next_page_id) {
url = `https://api.com/?id_user=${$('SourceData').item.json.user_id}&next_max_id=${next_page_id}`;
} else {
url = `https://api.com/?id_user=${$('SourceData').item.json.user_id}`;
}
return [
{
json: {
url: url
}
}
];
and this is the code that is in the nextpage node:
// Get the global workflow static data
const workflowStaticData = $getWorkflowStaticData('global');
// Update its data
workflowStaticData.next_page_id = $('Call API').item.json.body.next_max_id;
return {};