amplience / dc-management-sdk-js

Amplience Dynamic Content Management SDK
https://amplience.github.io/dc-management-sdk-js/
Other
46 stars 14 forks source link

Unable to get an Event by id #136

Open easen-amp opened 1 year ago

easen-amp commented 1 year ago

Description

Unable to get an Event by its id, the only option is to list the events and try and find the event.

Steps to Reproduce

Expected Results

const hub = await dcClient.hubs.get(process.env.DC_HUB_ID);
const event = await hub.related.events.get(EVENT_ID);

Actual Results

Current work around

  const hub = await dcClient.hubs.get(process.env.DC_HUB_ID);

  let events: Page<Event>;
  let page = 0;
  let event;
  do {
    events = await hub.related.events.list({ page, size: 100 });
    event = events.getItems().find((event) => event.id == EVENT_ID);
    page++;
  } while (!event && events._links["next"]);

  if (event) {
    // do something 
  }

Affected browsers/environments

Versions

Other information

ashatch commented 1 year ago

It's just:

dcClient.events.get(eventId);