Skip to content

Instantly share code, notes, and snippets.

@alchemistake
Last active October 13, 2022 06:13
Show Gist options
  • Save alchemistake/9a2c620313311f03c7d9904248f72fc3 to your computer and use it in GitHub Desktop.
Save alchemistake/9a2c620313311f03c7d9904248f72fc3 to your computer and use it in GitHub Desktop.
Todoist Auto-Done Script for iOS
let task_get = new Request(`https://api.todoist.com/rest/v2/tasks/${task_id}`);
task_get.method = "get";
task_get.headers = {
"Authorization": `Bearer ${bearer_token}`,
"Content-Type": "application/json"
};
let res = await task_get.loadJSON();
let due = res["due"]["date"];
let due_date = new Date(due);
let today = new Date();
if (today >= due_date){
let task_done = new Request(`https://api.todoist.com/rest/v2/tasks/${task_id}/close`);
task_done.method = "post";
task_done.headers = {
"Authorization": `Bearer ${bearer_token}`,
"Content-Type": "application/json"
};
await task_done.load();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment