dc-management-sdk-js icon indicating copy to clipboard operation
dc-management-sdk-js copied to clipboard

Unable to get an Event by id

Open easen-amp opened this issue 2 years ago • 1 comments

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

  • [x] NodeJS 8.x
  • [x] NodeJS 10.x
  • [x] NodeJS 12.x

Versions

  • dc-management-sdk-js: all versions

Other information

easen-amp avatar Jan 27 '23 11:01 easen-amp

It's just:

dcClient.events.get(eventId);

ashatch avatar Jan 27 '23 15:01 ashatch