Hi, I have an API query that is cursor-based paginated (I believe). I have hit a wall here as I simply cannot get the rest of the data to load to my table. I have tried the cursor pagination function in Retool, and I have tried several approaches in JavaScript and with the URL, but I can't get anything to work.
The Problem
I want to have a table with all 680 results of my API call, but I am only getting a limited amount of results which I can set with the limit
API parameter (max 250). I can see that there is a next_page
element in the API call as well, and the value at index 1 of that array is the dispute ID of my API call. Now I though I might need to sort_by
the API call and set the next page to one of the values in the next_page
array, however, I cannot sort_by
dispute ID. (The dispute ID can be found at the dispute_krn
key as the last value after the :
in that string.)
API call result
If I run the API query with a limit
of 1, this is the result I get:
{
"pagination": {
"limit": 1,
"count": 1,
"total": 687,
"next_page": [
"1678799406473",
"205362922"
]
},
"disputes": [
{
"dispute_krn": "krn:klarna:eu1:dispute:return:205362922",
"investigation_status": "closed",
"reason": "return",
"opened_at": "2023-03-14T13:10:06.473Z",
"closed_at": "2023-06-22T10:36:52.206Z",
"closing_reason": "resolved",
"capture_id": "a1c5f37b-7009-4852-a451-f96860a04322",
"region": "eu1",
"order": {
// A lot of data that is not important
],
"status": "closed",
"disputed_amount": {
"amount": 69900,
"currency": "SEK"
}
}
]
}
Desired situation
I want all the 680 records of this API call to end up in my table in Retool. I am guessing I will need to iterate over this API call with some JavaScript code. The problem is that I don't know what values to use for this JavaScript code, and the subsequent API calls.
Can somebody guide me in the right direction here?