title: Merging two different Fetch calls with data from Jsonplaceholder.com
body: <p>I am trying to merge or basically perform an inner join on two datasets provided by <code>https://jsonplaceholder.typicode.com/comments</code> and <code>https://jsonplaceholder.typicode.com/posts</code>. The join would of course be using the <code>PostId</code> and <code>id</code> keys of both data sets respectively; however I am unsure of how to actually do this. I've added my codepen: <a href="https://codepen.io/gabedesigns/pen/qMGgxY?editors=1111" rel="nofollow noreferrer">https://codepen.io/gabedesigns/pen/qMGgxY?editors=1111</a> and I seem to be getting an error saying that I am missing '()' for my constructor. After figuring this out I will also need to search for posts with provided post ID and the comments corresponding the post. Perhaps I need nested for loops in order to make this work? I've tried to look up some other information on this and couldn't seem to find much. If there are any other resources I may have skipped over please don't be afraid to link it below. I saw a post on here already talking about "inner joins" with javascript instead of SQL, but this is where I ran into some problems. Here is some code:</p>
  
  <pre><code>function getResults() {
  
    const equijoin = (xs, ys, primary, foreign, sel) =&gt; {
     const ix = xs.reduce((ix, row) =&gt; ix.set(row[primary], row), new Map());
      return ys.map(row =&gt; sel(ix.get(row[foreign]), row));
    };
  
    const postData = fetch("https://jsonplaceholder.typicode.com/posts")
     .then(function(response) {
       return response.json();
    });
  
    const commentData = fetch("https://jsonplaceholder.typicode.com/comments")
     .then(function(response) {
      return response.json();
    });
  
    const result = equijoin(postData, commentData,"id", "postId", ({title, 
    body}, {name,body}) =&gt; ({title,body,name}));
  
  }
  </code></pre>