facebook-graph-apifacebook-javascript-sdkfacebook-batch-request

Limit fields using JavaScript SDK Batch Request


Is it possible to limit the fields that are returned from Facebook's Batch request API using the JavaScript SDK? For example:

    FB.api('/', 'POST', {
        batch: [
            { method: 'GET', relative_url: 'me'},
            ...
        ]
    }, function (response) {
        console.log(response);
    });

The first method of the batch request above returns the full user graph. However, what if I only wanted to fetch a few fields (e.g. first_name and last_name). Something like this would be nice, but doesn't work:

        batch: [
            { method: 'GET', relative_url: 'me', fields: 'first_name,last_name'},
            ...
        ]

Solution

  • With some requests you can use the &fields= appended to the end of the url. like /me?fields=first_name,last_name