Packages
Fetch Drops

Fetch Drops

When retrieving Drops we have to paginate using offset and limit. But besides we can sort the results and filter them by many options.

import { Drop, DropsSortFields } from '@poap-xyz/drops';
import { Order, PaginatedResult } from '@poap-xyz/utils';
 
const paginatedDrops: PaginatedResult<Drop> = await client.fetch({
  offset: 0,
  limit: 10,
  sortField: DropsSortFields.Id,
  sortDir: Order.ASC,
});

Fetch single Drop

By giving the Drop ID we want to find, we can filter the pagination to contain the Drop or not.

import { Drop } from '@poap-xyz/drops';
import { PaginatedResult } from '@poap-xyz/utils';
 
const dropId = 14;
 
const paginatedDrops: PaginatedResult<Drop> = await client.fetch({
  offset: 0,
  limit: 10,
  ids: [dropId],
});
 
if (paginatedDrops.items.length === 0) {
  throw new Error('My super drop was not found');
}
 
const drop: Drop = paginatedDrops.items[0];