DEV Community

Discussion on: Is there a good temporary variable name that you use?

Collapse
 
klvenky profile image
Venkatesh KL

Ideally I would have multiple pages in such case the token would be used for fetching the next set of results. It's like a SQL cursor based pagination approach.

Collapse
 
qm3ster profile image
Mihail Malo

Then, in the style of my other answer:

async function getAllFooBar() {
  const all = []
  for await (const foo of getPaged('foo'))
    for await (const x of getPaged('bar', foo))
      all.push(x)
  return all
}
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
klvenky profile image
Venkatesh KL

Yep. That looks great. thanks.