Adaptating todoist sample pack - issue completing a task

Hi people,

i’m beginning my pack maker journey by improving todoist sample right here https://coda.io/packs/build/latest/samples/full/todoist/

I’ve set a CompleteTask() function that worked fine until today, by creating a post request to the url to complete the task

pack.addFormula({
  name: "CompleteTask",
  description: "CompleteATask.",
   parameters: [
    coda.makeParameter({
      type: coda.ParameterType.String,
      name: "taskId",
      description: "The ID of the task.",
    }),
 
  ],
 resultType: coda.ValueType.Object,

  schema: coda.withIdentity(TaskSchema, "Task"),
  isAction: true,
  execute: async function ([taskId], context) {
    let url = "https://api.todoist.com/rest/v2/tasks/" + taskId + "/close";
   
    let response = await context.fetcher.fetch({
      method: "POST",
      url: url,
    //  headers: {
      //  "Content-Type": "application/json",
      //},

    });
  },
});

I’m absolutely sure this code can be improved, but it worked for now.

For some unexplicable reason, since this morning I get this error, and of course I cannot understand why, since I did not touch anything in this function (I even reloaded previous code to cancel other part of code modification).

Formula in coda, task id beeing alright and fetched from the pack itself

image

Does anyone have an idea ?

Thanks

The problem is that you have a formula that should return an object that corresponds to the TaskSchema but you are not returning anything, which makes you return undefined.

To fix you need to return the task you just updated or change the return value of the action.

2 Likes