you can have a JS query that fetches each page, and appends to a state variable. here’s an example, where the stripe query is called fetchCustomersPage and the state variable is called allStripeCustomers
`async function fetchAll() {
let res = []
let data = await fetchCustomersPage.trigger()
res = res.concat(data.response.body.data)
allStripeCustomers.setValue(res)
while (data.response.body.has_more) {
const lastId = res[res.length - 1].id
data = await fetchCustomersPage.trigger({ additionalScope: { lastId } })
res = res.concat(data.response.body.data)
allStripeCustomers.setValue(res)
}
}
Hi Dave! I think I know what you mean – when we pass objects / arrays to Stripe through our existing integration we’re not properly URL encoding the parameters – is that right?
Thanks Abdul! That looks reasonable. If you don’t mind another question, in the larger scope of this post, I’m trying to fill in Stripe data to inform a table - it looks like Retool is invoking that resource each time I page through the table (which is probably fine). Are there any good strategies if I wanted to, say, prefetch all of the data and join it against something else before including it in a table?
I saw another post where Retool folks tried to implement a boundary-limit pager like Stripe uses, and found that it’s a pain in the butt (which is true - it’s not the same as a limit-offset pager). Prefetching everything would help mitigate some of those concerns.
you can have a JS query that fetches each page, and appends to a state variable. here’s an example, where the stripe query is called fetchCustomersPage and the state variable is called allStripeCustomers
`async function fetchAll() {
let res = []
let data = await fetchCustomersPage.trigger()
res = res.concat(data.response.body.data)
allStripeCustomers.setValue(res)
while (data.response.body.has_more) {
const lastId = res[res.length - 1].id
data = await fetchCustomersPage.trigger({ additionalScope: { lastId } })
res = res.concat(data.response.body.data)
allStripeCustomers.setValue(res)
}
}