How to combine merged arrays from http GET modules and match keys

I’m getting video data from Youtube and also the video’s channel’s data using two http modules. However, I want to reduce the operations for the iterations it takes to put the data in a Google spreadsheet. Using the flatten and merge array functions, I’ve managed to get them all in 1 operation, BUT i can’t map them to google sheets like this. so, I want to be able to match the channel id key from the video HTTP module, to the id key in the channel HTTP module, so that they combine.

I’ve tried using chatgpt to tell me the js code I can accomplish this, but I’m still lost.

here is the output from the merge iterator. The output puts all the youtube#channel kind bundles first, then the videos:

Here’s the code chatgpt told me to use:

let channel = {
  kind: "youtube#channel",
  etag: "wcT2KncGAhdhfoaHxyhZIxIiwHY",
  id: "UCHaSwvPfNrjZ9RZy17rAhPw",
  statisticsCollection: {
    viewCount: 5117220,
    subscriberCount: 34800,
    hiddenSubscriberCount: false,
    videoCount: 536
  }
};

let video = {
  kind: "youtube#video",
  etag: "pWYWHABuYu_goppGBGPhsr05UoU",
  id: "BX61XKNYvIY",
  snippetCollection: {
    publishedAt: "2022-11-09T04:14:24Z",
    channelId: "UCjSOwkYUtTDjDoPczoTv_Hw",
    title: "What is Airtable? And Is It For Me?",
    description: "Airtable is one of my favorite foundational tools that I use for a variety of projects, both for work and personally.",
    thumbnailsCollection: {},
    channelTitle: "Dan Leeman",
    categoryId: 27,
    liveBroadcastContent: "none",
    localizedCollection: {},
    defaultAudioLanguage: "en"
  },
  statisticsCollection: {
    viewCount: 162661,
    likeCount: 1965,
    favoriteCount: 0,
    commentCount: 63
  }
};

if (video.snippetCollection.channelId === channel.id) {
  let combinedData = {
    videoId: video.id,
    videoTitle: video.snippetCollection.title,
    videoPublishedAt: video.snippetCollection.publishedAt,
    videoDescription: video.snippetCollection.description,
    videoViewCount: video.statisticsCollection.viewCount,
    videoLikeCount: video.statisticsCollection.likeCount,
    videoCommentCount: video.statisticsCollection.commentCount,
    channelId: channel.id,
    channelTitle: video.snippetCollection.channelTitle,
    channelSubscriberCount: channel.statisticsCollection.subscriberCount,
    channelViewCount: channel.statisticsCollection.viewCount,
    channelVideoCount: channel.statisticsCollection.videoCount
  };

  return [combinedData];
} else {
  return [];
}

And here is my flow so far:

Code is completely useless in Make. Try not to use ChatGPT for questions about Make.

Looks like you are using too many Text Aggregators. If you want to use the same array order in a later module, you need to use an Array Aggregator instead.

Aggregators

Every result (item/record) from iterator/list/search/match modules will output a bundle. This can result in multiple bundles, which then trigger multiple operations in future modules (one operation per bundle). To “combine” multiple bundles into a single variable, you’ll need to use an aggregator of some sort.

Aggregators are modules that accumulate multiple bundles into one single bundle. An example of a commonly-used aggregator module is the Array aggregator module. The next popular aggregator is the Text Aggregator which is very flexible and can apply to many use-cases like building of JSON, CSV, HTML.

There are other types of aggregator modules, click the below links to find out more:

Array Aggregator – mapping multiple bundles into a complex field

The Array Aggregator module is very powerful because it allows you to build a complex array of collections for a later module’s field to map multiple items (collections) to it.

This is done using the “Target structure type” of an Array Aggregator module.

Here is an example:

As you can see, the “Map” toggle on complex fields are used when you have an array. You can easily build an array variable to map to a future module’s field, by using an Array Aggregator module and select the “Target Structure Type” as the future module’s field you have mapped the array into.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.