Examples
Events
Get all events with pagination using cursor
Since there can be a large number of events, they are paginated.
You can go through the results using the cursor
.
import { Client } from "@upstash/qstash";
const client = new Client({ token: "<QSTASH_TOKEN>" });
const allEvents = [];
let cursor = null;
while (true) {
const res = await client.events({ cursor });
allEvents.push(...res.events);
cursor = res.cursor;
if (!cursor) {
break;
}
}
Filter events by state and only return the first 50.
More filters can be found in the API Reference.
import { Client } from "@upstash/qstash";
const client = new Client({ token: "<QSTASH_TOKEN>" });
const res = await client.events({
filter: {
state: "DELIVERED",
count: 50
}
});