How to Modify Code to Filter the Correct Google Task List in a Notion Database Update Workflow?

This topic was automatically generated from Slack. You can find the original thread here.

My workflow for creating new tasks in google tasks when a database page is updated in notion is creating tasks in the wrong google task list. Can you create a prop in this code to make sure it’s filtering the correct list? This is the ID of the list: Mk1hZng3dVdLeEJ6ZVZqUg. This is the code

import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    google_tasks: {
      type: "app",
      app: "google_tasks",
    },
  },
  async run({ steps }) {
    const notionURL = steps.trigger.event.url;
    const existingTasks = steps.list_tasks.$return_value.filter(task => task.notes === notionURL);
    this.filteredTasks = existingTasks;
  }
});

To filter tasks based on the specific Google Task List ID, you can modify the code like this: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { google_tasks: { type: "app", app: "google_tasks", }, taskListId: { type: "string", label: "Task List ID", default: "Mk1hZng3dVdLeEJ6ZVZqUg", }, }, async run({ steps, $ }) { const notionURL = steps.trigger.event.url; const { data: taskList } = await axios($, { url: `https://www.googleapis.com/tasks/v1/lists/${this.taskListId}/tasks`, headers: { Authorization: `Bearer ${this.google_tasks.$auth.oauth_access_token}`, }, }); const existingTasks = taskList.items.filter(task => task.notes === notionURL); this.filteredTasks = existingTasks; } }); This code adds a new prop taskListId with the default value set to the provided Task List ID. The tasks are then fetched from the specified Task List, and filtered based on the notionURL.

This code seems to be creating the task in the wrong list too.

import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    google_tasks: {
      type: "app",
      app: "google_tasks",
    },
    title: {
      type: "string",
      label: "Notion Page Title",
    },
    notionUrl: {
      type: "string",
      label: "Notion Page URL",
    },
    dueDate: {
      type: "string",
      label: "Due Date",
    },
  },
  async run({ steps }) {
  const existingTasks = steps.google_tasks.filteredTasks;
  const title = this.title;
  const dueDate = this.dueDate;

  if (existingTasks && existingTasks.length > 0) {
    // Update the existing task's due date
    const taskId = existingTasks[0].id;
    const taskListId = existingTasks[0].taskListId;

      await axios(this, {
        method: "POST",
        url: `https://www.googleapis.com/tasks/v1/lists/${taskListId}/tasks/${taskId}`,
        headers: {
          Authorization: `Bearer ${this.google_tasks.$auth.oauth_access_token}`,
          "Content-Type": "application/json",
        },
        data: {
          due: dueDate,
        },
      });
    } else {
      // Create a new task
      const url = "https://www.googleapis.com/tasks/v1/lists/@default/tasks";
      const body = {
        title: title,
        due: dueDate,
        notes: this.notionUrl,
      };

      await axios(this, {
        method: "POST",
        url: url,
        headers: {
          Authorization: `Bearer ${this.google_tasks.$auth.oauth_access_token}`,
          "Content-Type": "application/json",
        },
        data: body,
      });
    }
  },
});

I see that the code is creating a new task in the “@default” task list when there are no existing tasks. To create the task in the correct list, you can replace the “@default” with the specific Task List ID you provided earlier. Here’s the updated code: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { google_tasks: { type: “app”, app: “google_tasks”, }, title: { type: “string”, label: “Notion Page Title”, }, notionUrl: { type: “string”, label: “Notion Page URL”, }, dueDate: { type: “string”, label: “Due Date”, }, taskListId: { type: “string”, label: “Task List ID”, default: “Mk1hZng3dVdLeEJ6ZVZqUg”, }, }, async run({ steps }) { const existingTasks = steps.google_tasks.filteredTasks; const title = this.title; const dueDate = this.dueDate; if (existingTasks && existingTasks.length > 0) { // Update the existing task’s due date const taskId = existingTasks[0].id; const taskListId = existingTasks[0].taskListId; await axios(this, { method: “POST”, url: https://www.googleapis.com/tasks/v1/lists/${taskListId}/tasks/${taskId}, headers: { Authorization: Bearer ${this.google_tasks.$auth.oauth_access_token}, “Content-Type”: “application/json”, }, data: { due: dueDate, }, }); } else { // Create a new task const url = https://www.googleapis.com/tasks/v1/lists/${this.taskListId}/tasks; const body = { title: title, due: dueDate, notes: this.notionUrl, }; await axios(this, { method: “POST”, url: url, headers: { Authorization: Bearer ${this.google_tasks.$auth.oauth_access_token}, “Content-Type”: “application/json”, }, data: body, }); } }, });

The code you just shared is giving me this error: TypeError
Cannot read properties of undefined (reading ‘filteredTasks’)
I believe it’s referencing the previous step that has this code:

This code:
import { axios } from@pipedream/platform”;

export default defineComponent({
props: {
google_tasks: {
type: “app”,
app: “google_tasks”,
},
taskListId: {
type: “string”,
label: “Task List ID”,
default: “Mk1hZng3dVdLeEJ6ZVZqUg”,
},
},
async run({ steps, $ }) {
const notionURL = steps.trigger.event.url;
const { data: taskList } = await axios($, {
url: https://www.googleapis.com/tasks/v1/lists/${**this**.taskListId}/tasks,
headers: {
Authorization: Bearer ${**this**.google_tasks.$auth.oauth_access_token},
},
});

**const** existingTasks = taskList.items.filter(task => task.notes === notionURL);
**this**.filteredTasks = existingTasks;

}
});

I apologize for the confusion. It seems the code you provided is trying to access steps.google_tasks.filteredTasks, but it’s not clear what the previous step named google_tasks is doing. To help you better, could you please provide the code for the google_tasks step or explain what it’s supposed to return? This will help me understand the issue and provide a solution.

I see that you’re trying to filter tasks based on the notionURL and store the filtered tasks in this.filteredTasks. The error you’re encountering is likely because you’re trying to access steps.google_tasks.filteredTasks in another step, but filteredTasks is not properly exported from this step. To fix this issue, you should export the existingTasks as a step export. Replace the line this.filteredTasks = existingTasks; with the following code: $.export("filteredTasks", existingTasks); This will make the filteredTasks available for use in the next steps of your workflow. In the next step, you can access it using steps.<step_name>.filteredTasks, where <step_name> is the name of the step where you’ve defined this code.

Why am I getting this error on the code TypeError
Cannot read properties of undefined (reading ‘items’)

import { axios } from@pipedream/platform”;

export default defineComponent({
props: {
google_tasks: {
type: “app”,
app: “google_tasks”,
},
taskListId: {
type: “string”,
label: “Task List ID”,
default: “Mk1hZng3dVdLeEJ6ZVZqUg”,
},
},
async run({ steps, $ }) {
const notionURL = steps.trigger.event.url;
const { data: taskList } = await axios($, {
url: https://www.googleapis.com/tasks/v1/lists/${**this**.taskListId}/tasks,
headers: {
Authorization: Bearer ${**this**.google_tasks.$auth.oauth_access_token},
},
});

**const** existingTasks = taskList.items.filter(task => task.notes === notionURL);
$.**export**(“filteredTasks”, existingTasks);

}
});

The error you’re encountering, TypeError Cannot read properties of undefined (reading ‘items’), is likely due to the taskList object not having an items property. This can happen if the API response is not in the expected format or if there’s an issue with the API request. To debug this issue, let’s log the taskList object to see its structure. Add a console.log(taskList) line right after the API request, like this: const { data: taskList } = await axios($, { url: `https://www.googleapis.com/tasks/v1/lists/${this.taskListId}/tasks`, headers: { Authorization: `Bearer ${this.google_tasks.$auth.oauth_access_token}`, }, }); console.log(taskList); const existingTasks = taskList.items.filter(task => task.notes === notionURL); $.export("filteredTasks", existingTasks); Now, run the workflow and check the logs to see the structure of the taskList object. This will help you identify if there’s any issue with the API response or if you need to modify the code to access the items property correctly.

I used this code. Did I input it in correctly?

import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    google_tasks: {
      type: "app",
      app: "google_tasks",
    },
    taskListId: {
      type: "string",
      label: "Task List ID",
      default: "Mk1hZng3dVdLeEJ6ZVZqUg",
    },
  },
  async run({ steps, $ }) {
    const { data: taskList } = await axios($, {
  url: `https://www.googleapis.com/tasks/v1/lists/${this.taskListId}/tasks`,
  headers: {
    Authorization: `Bearer ${this.google_tasks.$auth.oauth_access_token}`,
  },
});

console.log(taskList);

const existingTasks = taskList.items.filter(task => task.notes === notionURL);
$.export("filteredTasks", existingTasks);
  }
});

It looks like you’ve missed defining the notionURL variable in your code. You should define it before using it in the filter function. Assuming you want to get the notionURL from the trigger event, you can add the following line right after the async run({ steps, $ }) {: const notionURL = steps.trigger.event.url; Here’s the updated code: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { google_tasks: { type: "app", app: "google_tasks", }, taskListId: { type: "string", label: "Task List ID", default: "Mk1hZng3dVdLeEJ6ZVZqUg", }, }, async run({ steps, $ }) { const notionURL = steps.trigger.event.url; const { data: taskList } = await axios($, { url: `https://www.googleapis.com/tasks/v1/lists/${this.taskListId}/tasks`, headers: { Authorization: `Bearer ${this.google_tasks.$auth.oauth_access_token}`, }, }); console.log(taskList); const existingTasks = taskList.items.filter(task => task.notes === notionURL); $.export("filteredTasks", existingTasks); } }); This should fix the issue and allow you to filter tasks based on the notionURL.

When I used this code

import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    google_tasks: {
      type: "app",
      app: "google_tasks",
    },
    taskListId: {
      type: "string",
      label: "Task List ID",
      default: "Mk1hZng3dVdLeEJ6ZVZqUg",
    },
  },
  async run({ steps, $ }) {
    const notionURL = steps.trigger.event.url;
    const { data: taskList } = await axios($, {
      url: `https://www.googleapis.com/tasks/v1/lists/${this.taskListId}/tasks`,
      headers: {
        Authorization: `Bearer ${this.google_tasks.$auth.oauth_access_token}`,
      },
    });

    console.log(taskList);

    const existingTasks = taskList.items.filter(task => task.notes === notionURL);
    $.export("filteredTasks", existingTasks);
  }
});

I got this error: TypeError
Cannot read properties of undefined (reading ‘items’)
The log just says, “undefined”

When I used this code

import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    google_tasks: {
      type: "app",
      app: "google_tasks",
    },
    taskListId: {
      type: "string",
      label: "Task List ID",
      default: "Mk1hZng3dVdLeEJ6ZVZqUg",
    },
  },
  async run({ steps, $ }) {
    const notionURL = steps.trigger.event.url;
    const { data: taskList } = await axios($, {
      url: `https://www.googleapis.com/tasks/v1/lists/${this.taskListId}/tasks`,
      headers: {
        Authorization: `Bearer ${this.google_tasks.$auth.oauth_access_token}`,
      },
    });

    console.log(taskList);

    const existingTasks = taskList.items.filter(task => task.notes === notionURL);
    $.export("filteredTasks", existingTasks);
  }
});

I got this error: TypeError
Cannot read properties of undefined (reading ‘items’)
The log just says, “undefined” (edited)

I apologize for the confusion. It seems like the taskList object might not have the expected structure, causing the error when trying to access the items property. Let’s add a check to handle this case and log the entire response for debugging purposes. Here’s the updated code: ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { google_tasks: { type: “app”, app: “google_tasks”, }, taskListId: { type: “string”, label: “Task List ID”, default: “Mk1hZng3dVdLeEJ6ZVZqUg”, }, }, async run({ steps, $ }) { const notionURL = steps.trigger.event.url; const response = await axios($, { url: https://www.googleapis.com/tasks/v1/lists/${this.taskListId}/tasks, headers: { Authorization: Bearer ${this.google_tasks.$auth.oauth_access_token}, }, }); console.log(“Response:”, response); if (response && response.items) { const existingTasks = response.items.filter(task => task.notes === notionURL); $.export(“filteredTasks”, existingTasks); } else { console.log(“No items found in the response.”); } } });

This is the majority of the log: Response: {
kind: ‘tasks#tasks’,
etag: ‘“LTEyOTY3MjYwOTQ”’,
nextPageToken: ‘CgwIjMmXqAYQmKGJpwMaEFBzQkFUNDJtdkJhSUtUSFY=’,
items: [
{
kind: ‘tasks#task’,
id: ‘RGV4Q3plQ2xoVHdpTUpMdg’,
etag: ‘“LTEyOTY2NTQzOTE”’,
title: ‘Come up with a generosity communication plan for integrity draft’,
updated: ‘2023-09-20T13:10:27.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/RGV4Q3plQ2xoVHdpTUpMdg’,
position: ‘00000000000000000003’,
notes: ‘https://www.notion.so/Come-up-with-a-generosity-communication-plan-for-integrity-draft-type-work-7bc0700733c24cc6845a073e4869c249’,
status: ‘needsAction’,
due: ‘2023-09-21T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘cTdGRnQ4UW4xSkpYNFEwcg’,
etag: ‘“LTEyOTY2NTU2OTM”’,
title: ‘Come up with a generosity communication plan for integrity draft’,
updated: ‘2023-09-20T13:10:26.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/cTdGRnQ4UW4xSkpYNFEwcg’,
position: ‘00000000000000000002’,
notes: ‘https://www.notion.so/Come-up-with-a-generosity-communication-plan-for-integrity-draft-type-work-7bc0700733c24cc6845a073e4869c249’,
status: ‘needsAction’,
due: ‘2023-09-21T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘bzlLUVFnUUo3Sk5zRGxRRw’,
etag: ‘“LTEyOTY2NTU5NTI”’,
title: ‘Mow yard’,
updated: ‘2023-09-20T13:10:25.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/bzlLUVFnUUo3Sk5zRGxRRw’,
position: ‘00000000000000000001’,
notes: ‘https://www.notion.so/Mow-yard-type-personal-0bc72950141f47d3a1b8561d29f05406’,
status: ‘needsAction’,
due: ‘2023-09-20T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘UlZSOUNLQXZrYTVjTnYwbg’,
etag: ‘“LTEyOTY2NTcxMTQ”’,
title: ‘Look up Lencioni’s conflict exercises’,
updated: ‘2023-09-20T13:10:24.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/UlZSOUNLQXZrYTVjTnYwbg’,
position: ‘00000000000000000000’,
notes: ‘https://www.notion.so/Look-up-Lencioni-s-conflict-exercises-For-2-hours-type-personal-96b262325e6d438096dc19c34933de10’,
status: ‘needsAction’,
due: ‘2023-09-20T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘NFBrQ0xhMHFOeFIyQVh4Qw’,
etag: ‘“LTEyOTY3MjA2MTY”’,
title: ‘Mow yard’,
updated: ‘2023-09-20T13:09:21.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/NFBrQ0xhMHFOeFIyQVh4Qw’,
position: ‘00000000000000000004’,
notes: ‘https://www.notion.so/Mow-yard-type-personal-0bc72950141f47d3a1b8561d29f05406’,
status: ‘needsAction’,
due: ‘2023-09-20T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘NHNlVDNndDB6Szd5YjFrUg’,
etag: ‘“LTEzNTU3MDgyMDY”’,
title: ‘Figure out the tags deal for the site’,
updated: ‘2023-09-19T20:46:13.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/NHNlVDNndDB6Szd5YjFrUg’,
position: ‘00000000000000000006’,
notes: ‘https://www.notion.so/Figure-out-the-tags-deal-for-the-site-for-1hr-type-work-caf11401bbcc4cb298ba401f75f19624’,
status: ‘needsAction’,
due: ‘2023-09-19T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘RlVaOTJScVVISWFiVlBzdA’,
etag: ‘“LTEzNTU3MDg0MjY”’,
title: ‘Check out the writing from FBC on how they were able to stop restricted funds’,
updated: ‘2023-09-19T20:46:13.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/RlVaOTJScVVISWFiVlBzdA’,
position: ‘00000000000000000005’,
notes: ‘https://www.notion.so/check-out-the-writing-from-FBC-on-how-they-were-able-to-stop-restricted-funds-Type-Work-b5151c3f77354ce894f5a92d8b87fae5’,
status: ‘needsAction’,
due: ‘2023-09-21T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘cnR6WXNBbDE2UzNsU2RJSA’,
etag: ‘“LTEzNTU3NjQ1ODM”’,
title: ‘New Giver Follow UP’,
updated: ‘2023-09-19T20:45:17.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/cnR6WXNBbDE2UzNsU2RJSA’,
position: ‘00000000000000000007’,
notes: ‘https://www.notion.so/New-Giver-Follow-UP-f1530bc8ca9345b8a187f50132bec07a’,
status: ‘needsAction’,
due: ‘2023-09-19T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘bHdtTFBSWWRHZEdwejlHSw’,
etag: ‘“LTEzNTYyMTYwMjQ”’,
title: ‘Fwd: Integrity Church check signing’,
updated: ‘2023-09-19T20:37:45.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/bHdtTFBSWWRHZEdwejlHSw’,
position: ‘00000000000000000011’,
notes: ‘https://www.notion.so/Fwd-Integrity-Church-check-signing-type-work-e8546cca84c24453bfd5988ee9bd3cc5’,
status: ‘needsAction’,
due: ‘2023-09-20T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘YVNXUWJKSnRKNldNVnB2WA’,
etag: ‘“LTEzNTYyMTcyOTA”’,
title: ‘Chechen on paying the bills on the desk’,
updated: ‘2023-09-19T20:37:45.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/YVNXUWJKSnRKNldNVnB2WA’,
position: ‘00000000000000000009’,
notes: ‘https://www.notion.so/Chechen-on-paying-the-bills-on-the-desk-For-2-hours-type-personal-5263a458df0c4fac83c977ccce6003d1’,
status: ‘needsAction’,
due: ‘2023-09-22T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘d1ZuTjR1alBpX2NjZlpLXw’,
etag: ‘“LTEzNTYyMTc1MDU”’,
title: ‘Fwd: Spreadsheet shared with you: “Field Staff Job Description-Cameron Loy”’,
updated: ‘2023-09-19T20:37:44.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/d1ZuTjR1alBpX2NjZlpLXw’,
position: ‘00000000000000000008’,
notes: ‘https://www.notion.so/Fwd-Spreadsheet-shared-with-you-Field-Staff-Job-Description-Cameron-Loy-for-1hr-type-work-b3ba61c9a3de48f780c8bd4603dbb954’,
status: ‘needsAction’,
due: ‘2023-09-20T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘NkNMUl9fWUJVMnh5bUpySw’,
etag: ‘“LTEzNTYyMzY5MzA”’,
title: ‘check with the elders on changing the bylaws (Type Work)’,
updated: ‘2023-09-19T20:37:24.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/NkNMUl9fWUJVMnh5bUpySw’,
position: ‘00000000000000000010’,
notes: ‘https://www.notion.so/check-with-the-elders-on-changing-the-bylaws-Type-Work-9bcb098058694d9f8c88d54fb3d60b2e’,
status: ‘needsAction’,
due: ‘2023-09-20T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘bW91OUJQUDcxbW0zOFl6OQ’,
etag: ‘“LTEzNTYyNDAyNDk”’,
title: ‘Look through the resources that Mark sent me’,
updated: ‘2023-09-19T20:37:21.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/bW91OUJQUDcxbW0zOFl6OQ’,
position: ‘00000000000000000012’,
notes: ‘https://www.notion.so/Look-through-the-resources-that-Mark-sent-me-27fd0c2182ac4544906a2235819dd843’,
status: ‘needsAction’,
due: ‘2023-09-20T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘dTh6elpMM1BJcHNyempGTQ’,
etag: ‘“LTEzNTY3OTczMjc”’,
title: ‘Look up Lencioni’s conflict exercises’,
updated: ‘2023-09-19T20:28:04.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/dTh6elpMM1BJcHNyempGTQ’,
position: ‘00000000000000000013’,
notes: ‘https://www.notion.so/Look-up-Lencioni-s-conflict-exercises-For-2-hours-type-personal-96b262325e6d438096dc19c34933de10’,
status: ‘needsAction’,
due: ‘2023-09-20T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘c25ZTUhHY1VSVjYyalkyNg’,
etag: ‘“LTEzNTY5MjU4NjI”’,
title: ‘Search Steve cuss conflict’,
updated: ‘2023-09-19T20:25:56.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/c25ZTUhHY1VSVjYyalkyNg’,
position: ‘00000000000000000014’,
notes: ‘https://www.notion.so/Search-Steve-cuss-conflict-For-2-hours-type-personal-23b28e87c53e44eb96887ccb425a221b’,
status: ‘needsAction’,
due: ‘2023-09-20T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘QjlaVklfRkRuaGozenZ4Wg’,
etag: ‘“LTEzNTcwMjg1MjY”’,
title: ‘New Giver Follow UP’,
updated: ‘2023-09-19T20:24:13.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/QjlaVklfRkRuaGozenZ4Wg’,
position: ‘00000000000000000015’,
notes: ‘https://www.notion.so/New-Giver-Follow-UP-f1530bc8ca9345b8a187f50132bec07a’,
status: ‘needsAction’,
due: ‘2023-09-20T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘ZmxCYlF0OWxyRlRtb0hJSA’,
etag: ‘“LTEzNjQ3NjA0MDQ”’,
title: ‘New Giver Follow UP’,
updated: ‘2023-09-19T18:15:21.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/ZmxCYlF0OWxyRlRtb0hJSA’,
position: ‘00000000000000000016’,
notes: ‘https://www.notion.so/New-Giver-Follow-UP-f1530bc8ca9345b8a187f50132bec07a’,
status: ‘needsAction’,
due: ‘2023-09-19T00:00:00.000Z’,
links: []
},
{
kind: ‘tasks#task’,
id: ‘V1NINHRfNk9sUFRYX1ZDNQ’,
etag: ‘“LTEzNzI4MzI2NDM”’,
title: ‘Check session 2, 3, and 4 for the retreat’,
updated: ‘2023-09-19T16:00:49.000Z’,
selfLink: ‘https://www.googleapis.com/tasks/v1/lists/Mk1hZng3dVdLeEJ6ZVZqUg/tasks/V1NINHRfNk9sUFRYX1ZDNQ’,
position: ‘00000000000000000017’,
notes: ‘https://www.notion.so/Check-session-2-3-and-4-for-the-retreat-9aad8c6669ae437d9dd93a3befce1f32’,

the export on the step shows that there are no filtered tasks though.

I understand that you’re not seeing the expected filtered tasks in the step export. To help you further, I need more information about your workflow and the specific step you’re referring to. Can you please provide more details about the step and the filtering logic you’re using?

Here’s the code for the filtering step:

import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    google_tasks: {
      type: "app",
      app: "google_tasks",
    },
    taskListId: {
      type: "string",
      label: "Task List ID",
      default: "Mk1hZng3dVdLeEJ6ZVZqUg",
    },
  },
  async run({ steps, $ }) {
    const notionURL = steps.trigger.event.url;
    const response = await axios($, {
      url: `https://www.googleapis.com/tasks/v1/lists/${this.taskListId}/tasks`,
      headers: {
        Authorization: `Bearer ${this.google_tasks.$auth.oauth_access_token}`,
      },
    });

    console.log("Response:", response);

    if (response && response.items) {
      const existingTasks = response.items.filter(task => task.notes === notionURL);
      $.export("filteredTasks", existingTasks);
    } else {
      console.log("No items found in the response.");
    }
  }
});

I noticed an issue in your code related to the URL and the response handling. The URL should not have angle brackets < and >. Also, you should access the items property from the response.data. Here’s the corrected code: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { google_tasks: { type: "app", app: "google_tasks", }, taskListId: { type: "string", label: "Task List ID", default: "Mk1hZng3dVdLeEJ6ZVZqUg", }, }, async run({ steps, $ }) { const notionURL = steps.trigger.event.url; const response = await axios($, { url: `https://www.googleapis.com/tasks/v1/lists/${this.taskListId}/tasks`, headers: { Authorization: `Bearer ${this.google_tasks.$auth.oauth_access_token}`, }, }); console.log("Response:", response); if (response.data && response.data.items) { const existingTasks = response.data.items.filter(task => task.notes === notionURL); $.export("filteredTasks", existingTasks); } else { console.log("No items found in the response."); } } }); This should fix the issue with the URL and properly filter the tasks based on the notionURL.