Returning events that have bookings inside

Hei guys!

I’m having a bad time! I need return in my route only events with bookings inside, and i’m trying like this:

  setupController(controller, model) {
    controller.set('events','event').then((events) => {
      return events.filter((event) => {
        let bookings ='booking', {

        if (bookings.get('length')) {
          return event;

The problem is: The request is async, so isn’t returning anything.

How could i solve this problem?

Thanks guys!

Try moving that piece of code out of setupController() and into model().

Then access all the events by the model instead of the controller property ‘events’