I'm new in javascript and I'm trying to get a bunch of task from different projects from todoist and trying to assign a label for those tasks.
const task_list = {};
for (let id of project_id) {
api.getTasks({
projectId: id, filter: "(today | overdue | p1) & !subtask"
})
.then((tasks) => { Object.assign(task_list, { id: tasks }); console.log(task_list)})
.catch((error) => console.log(error))
}
for (let id of project_id) {
console.log(id)
console.log(task_list.id)
}
This is currently my draft for the code. The console.log in the for loop at the bottom is printing undefined but the console.log behind the Object.assign is able to print out the correct output.
Please help.