Function
Static Public Summary | ||
public |
|
|
public |
async getPaginatedRange(page: Promise<PaginatedResourceListing> | PaginatedResourceListing, start: Number, stop: Number): Promise<Array<ResourceBase>> Get all the pages from a PaginatedResourceListing or a range |
Static Public
public clone(input: *, clonePrivate: boolean): * source
import {clone} from '@mapcreator/api/src/utils/helpers.js'
Params:
Name | Type | Attribute | Description |
input | * | ||
clonePrivate | boolean |
|
Return:
* |
public async getPaginatedRange(page: Promise<PaginatedResourceListing> | PaginatedResourceListing, start: Number, stop: Number): Promise<Array<ResourceBase>> source
import {getPaginatedRange} from '@mapcreator/api/src/utils/helpers.js'
Get all the pages from a PaginatedResourceListing or a range
Params:
Name | Type | Attribute | Description |
page | Promise<PaginatedResourceListing> | PaginatedResourceListing | Promise that returns a PaginatedResourceListing |
|
start | Number |
|
Start page |
stop | Number |
|
Stop page, defaults to the page count if not filled in. |
Throw:
If the api returns errors |
Example:
import { helpers } from "@mapcreator/api";
const promise = api.users.list(1, 50); // 50 per page is more efficient
helpers.getPaginatedRange(promise).then(data => {
data.map(row => `[${row.id}] ${row.name}`) // We just want the names
.forEach(console.log) // Log the names and ids of every user
})