title: Trouble building FB.api query
body: <p>OK so I'm working on a Facebook Group Feed that loads more results, but I'm having trouble building the initial query for it all to work.</p>
  
  <p>In the first <code>if</code> statement below, you can see where I put the parts of the query into variables and then call the function, passing those variables. This all works fine...</p>
  
  <pre><code>if (response.status === 'connected') {
  // Logged into your app and Facebook.
  console.log('Welcome!  Fetching your information.... ');
  
  var path = '/', 
      method = 'POST',
      params = {
        batch: [
          {method : 'GET', name : 'user', relative_url : '/me?fields=id,name,picture'},
          {method: 'GET', name : 'post-ids', relative_url: '/group-id/feed?fields=fields{with field expansion}',omit_response_on_success : false}
        ]
      };
  
  loadFeed(path, method, params);
  
  }
  </code></pre>
  
  <p>The funciton below is where I'm having trouble. The first time the function is called, I need to put those three variables together into one, and call it with FB.api. You can see the function here:</p>
  
  <pre><code>function loadFeed(path, method, params) {
  
      console.log('------------------');
      console.log(path + ', ' + method + ', ' + params);
  
      if(path != 'undefined') {
        if(method != 'undefined') {
          if(params != 'undefined') { var query = '{\'' + path + '\', \'' + method + '\', ' + params + '}'; } 
        } 
        else { var query = path; }
      } 
  
      $('#load-more').css('display', 'hidden');
  
      FB.api(query, function (response) {
          console.log(response);
  
        // first time page loads, response[0] is the login, and response[1] is the feed
        // each time after that, response[0] is the feed
  
        if(response.length &gt; 1) {
          var membody = JSON.parse(response[0].body),
              feed = JSON.parse(response[1].body);
        } else {
          var feed = JSON.parse(response);
        }
  
        if(feed.paging) {
  
          if(feed.paging.next) {
  
            var load_more = '&lt;div id="load-more"&gt;&lt;center&gt;Load more&lt;/center&gt;&lt;/div&gt;',
                method = '',
                params = '';
  
            $('#feed').append(load_more);
  
            $('#load-more').click( function() {
              loadFeed(feed.paging.next);
            });
  
          }
  
        }
  
      });
  }
  </code></pre>
  
  <p>On the first call of this function, I get this error:</p>
  
  <pre><code>error: Object
      code: 2500
      message: "Unknown path components: /', 'POST', [object Object]}"
      type: "OAuthException"
  </code></pre>
  
  <p>This seems to tell me that I've basically put the query together wrong, but I've tried a few different things and none of it is working. You can see in the error message that there's a missing single quote at the beginning of the query, and I've not been able to figure out how to keep the single quote there.</p>
  
  <p>Does anyone have any ideas on how I can fix this problem?</p>
  
  <p>Also, if you know a better way to do all this then I'd appreciate that as well!</p>