Why does the provided code hang?

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

— Why would the following code you wrote hang?

I apologize if the code I provided caused any issues. To help you better, can you please provide the code that’s causing the problem? This will help me understand the issue and provide a solution.

— Here is the code:

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

export default defineComponent({
  props: {
    notionApiKey: {
      type: "string",
      label: "Notion API Key",
      secret: true,
    },
    databaseId: {
      type: "string",
      label: "Notion Database ID",
    },
  },
  async run({ steps }) {
    const youtubeVideos = steps.get_youtube_videos.$return_value;
    const notionDbSchema = steps.get_notion_db_schema;

    const createNotionPage = async (video) => {
      const { name, description, video_url, thumbnail_url } = video;

      const newPage = {
        "Name": {
          "title": [
            {
              "text": {
                "content": name,
              },
            },
          ],
        },
        "Description": {
          "rich_text": [
            {
              "text": {
                "content": description,
              },
            },
          ],
        },
        "Video URL": {
          "url": video_url,
        },
        "Thumbnail": {
          "url": thumbnail_url,
        },
      };

      try {
        await axios(this, {
          method: "POST",
          url: `https://api.notion.com/v1/pages`,
          headers: {
            "Authorization": `Bearer ${this.notionApiKey}`,
            "Content-Type": "application/json",
            "Notion-Version": "2022-05-13",
          },
          data: {
            "parent": {
              "database_id": this.databaseId,
            },
            "properties": newPage,
          },
        });
      } catch (error) {
        console.error(`Error creating Notion page for video: ${name}`);
        console.error(error);
      }
    };

    for (const video of youtubeVideos) {
      await createNotionPage(video);
    }
  },
});

what was the error you received?

— Error creating Notion page for video:

The error thrown by the script.

— What does this error mean?

export: debug - {
  "status": 404,
  "statusText": "Not Found",
  "headers": {
    "date": "Tue, 06 Jun 2023 05:28:59 GMT",
    "content-type": "application/json; charset=utf-8",
    "content-length": "217",
    "connection": "close",
    "x-powered-by": "Express",
    "etag": "W/\"d9-Be2VG8szXMtqlPgZ2J7Ykqi6C3I\"",
    "vary": "Accept-Encoding",
    "cf-cache-status": "DYNAMIC",
    "set-cookie": [
      "__cf_bm=35OB5D5tm2OktUSwR4uDxy4gnns5FdHYsHE2UF1FYBU-1686029339-0-AdiwRz4yQhVPMcfW5GX2I/AU8jBJSA2rch+v4wQEXVJwgxJtqfgEbnq+IE1QOmCoImCt4gKBVbfJy/SjR9M1jes=; path=/; expires=Tue, 06-Jun-23 05:58:59 GMT; domain=.[notion.com](http://notion.com); HttpOnly; Secure; SameSite=None"
    ],
    "server": "cloudflare",
    "cf-ray": "7d2e414c2de10840-IAD"
  },
  "config": {
    "url": "https://api.notion.com/v1/pages",
    "method": "post",
    "data": "{\"parent\":{\"database_id\":\"c31ec563-786c-431e-9cd5-5cbb4eedb235\"},\"properties\":{\"name\":{\"title\":[{\"text\":{\"content\":\"Find Photos Fast with QuickFilters in Mylio Photos\"}}]},\"description\":{\"rich_text\":[{\"text\":{\"content\":\"Are you tired of endlessly scrolling through your photo library to find that one perfect shot? Say hello to Mylio Photos' new ...\"}}]},\"video_url\":{\"url\":\"https://www.youtube.com/watch?v=PVY7krROuYQ\"},\"thumbnail_url\":{\"url\":\"https://i.ytimg.com/vi/PVY7krROuYQ/default.jpg\"},\"video_source\":{\"rich_text\":[{\"text\":{\"content\":\"Youtube\"}}]}}}",
    "headers": {
      "Accept": "application/json, text/plain, **/**",
      "Content-Type": "application/json",
      "Authorization": "Bearer secret_DAK3zxqk2D5gekb16Yeh9oTLKcoX2hE80EszAtebfYk",
      "Notion-Version": "2022-06-28",
      "User-Agent": "axios/0.21.4",
      "Content-Length": 557
    },
    "transformRequest": [
      null
    ],
    "transformResponse": [
      null
    ],
    "timeout": 0,
    "xsrfCookieName": "XSRF-TOKEN",
    "xsrfHeaderName": "X-XSRF-TOKEN",
    "maxContentLength": -1,
    "maxBodyLength": -1,
    "transitional": {
      "silentJSONParsing": true,
      "forcedJSONParsing": true,
      "clarifyTimeoutError": false
    }
  },
  "data": {
    "object": "error",
    "status": 404,
    "code": "object_not_found",
    "message": "Could not find database with ID: c31ec563-786c-431e-9cd5-5cbb4eedb235. Make sure the relevant pages and databases are shared with your integration."
  }
}