Viewing readonly version: 8View latest version
Script
This val exports a function that loops through paginated API responses and returns the combined data as an array. It expects pagination with next
and there to be a data
property in the API response. This conforms to the Val Town API, so this function is useful when fetching paginated Val Town API responses for creating custom folders in pomdtr's vscode extension.
Usage:
const id = <vt user id>
await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {
headers: { Authorization: `Bearer ${Deno.env.get("valtown")}` },
});
For demo usage in the context of the vscode extension see this val.