TypeError: $schedule.create(...).catch is not a function

Anyone got any ideas on what causes this one?

Its not happening when I run it from the FDK web tests in my dev environment. It only happens when I have installed the app as a custom app. Then it gets reported as an error in the logs. I have also started dabbling with creating unit tests and saw it there too.

Weirdly though the schedule still gets created in the custom app when installed.

You’re right, @RobAtOpinyin. This is yet another undocumented behaviour. Apologies for the confusion.

Meanwhile, I tested this and found that there is a .fail() method. Our docs probably still say that there should be a .catch() method. I am trying to get more details on this, on whether this is a change in behaviour or a bug.

1 Like

@RobAtOpinyin Can you update FDK to 7.5.0 and try the same? I could reproduce this with 7.5.0 locally as well.

So, this doesn’t work:

$schedule
  .create({
    name: "test_schedule",
    data: { counter: ++counter },
    schedule_at: new Date(Date.now() + 10000).toISOString(), // 10 seconds in the future
    repeat: {
      time_unit: "minutes",
      frequency: 1,
    },
  })
  .catch(function (e) {
    console.log("I got thrown an error", e);
  });

But, this works:

$schedule
  .create({
    name: "test_schedule",
    data: { counter: ++counter },
    schedule_at: new Date(Date.now() + 10000).toISOString(), // 10 seconds in the future
    repeat: {
      time_unit: "minutes",
      frequency: 1,
    },
  })
  .fail(function (e) {
    console.log("I got thrown an error", e);
  });

Sample app I wrote to test:

schedule-fn-test.zip (2.6 KB)

@RobAtOpinyin Updates:

  1. You can use the .fail() method instead.
  2. We are doing some changes internally to remove jQuery deferred dependency for FDK. We are yet to decide which methods will be available from a returned Promise. Whether will have only .fail() or have .catch() and .fail().
  3. However, you might want to use async/await and avoid these changes.

Hi Kaustav,

Thanks for investigating this for me. That’s excellent and it explains why it still schedules the event but the code fails. I am still using FDK 7.1.0 as I am having challenges getting FDK to upgrade at the moment. See here:- FDK update is not working

I am refactoring most of the code to async/await as I work on it but hadn’t got to that bit yet.

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.