search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Loading events from multiple sources (onto Scheduler)

Asked by TomHH
1 year ago.

I want to load and display events from more than one source.

I'm currently using:"api/rotaevents/list/2?format=dp_events");"api/events/list?format=dp_events");

but this only shows events from one source, when I inspect, I can only see the one list of events.

How can I load and show both on the same scheduler?

Comment posted by TomHH
1 year ago.

I should add, that if both sources have 'clashing' events, then they should be displayed stacked.

Answer posted by Dan Letecky [DayPilot]
1 year ago.

You need to make two requests manually and merge the results into a single array.

The following example uses two parallel requests, waits until both return a result and update the Scheduler:

const start = dpRota.visibleStart();
const end = dpRota.visibleEnd();

const p1 = fetch(`api/rotaevents/list/2?format=dp_events&start=${start}&end=${end}`).then(response => response.json());
const p2 = fetch(`api/events/list?format=dp_events&start=${start}&end=${end}`).then(response => response.json());

const [e1, e2] = await Promise.all([p1, p2]);

const events = e1.concat(e2);


See also:

Comment posted by TomHH
1 year ago.

Thank you!

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.