Packages
Drops
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,
  Order,
  PaginatedResult,
} from '@poap-xyz/poap-sdk';
 
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, PaginatedResult } from '@poap-xyz/poap-sdk';
 
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];