Fetch Moments
List Moments
Fetching moments per page are done by giving an offset
and a limit
. This way
all the uploaded moments could be retrieved.
import { Moment } from '@poap-xyz/moments';
import { Order, PaginatedResult } from '@poap-xyz/utils';
const paginatedMoments: PaginatedResult<Moment> = await client.fetch({
offset: 0,
limit: 10,
idOrder: Order.DESC,
});
By Drop
The list can be filtered by one or more Drops by giving drop_ids
list with the
Drop IDs. Also, the list can be sorted by id
or created
.
import { Moment } from '@poap-xyz/moments';
import { Order, PaginatedResult } from '@poap-xyz/utils';
const dropId = 14;
const paginatedMoments: PaginatedResult<Moment> = await client.fetch({
offset: 0,
limit: 10,
drop_ids: [dropId],
idOrder: Order.DESC,
});
Fetch single Moment
import { Moment } from '@poap-xyz/moments';
import { PaginatedResult } from '@poap-xyz/utils';
const momentId = '7284219b-1bc7-43b8-ab27-44749bdd91e1';
const paginatedMoments: PaginatedResult<Moment> = await client.fetch({
offset: 0,
limit: 1,
id: momentId,
});
if (paginatedMoments.items.length === 0) {
throw new Error('My moment does not exists');
}
const moment: Moment = paginatedMoments.items[0];